Ñò h'dWc@s dZddkZddkZddklZlZlZlZl Z l Z l Z l Z l Z lZddklZlZlZlZde fd„ƒYZdS(s AI Manifest Interface iÿÿÿÿN( tCriteriat AIServerErrort ERROR_TYPEtSERVICE_STATUStEventsGeneratortObjectChangedEventt DeletedEventt CreatedEventt check_authst MANIFEST_AUTH(t ai_databasetget_server_instancetlogtMAX_MANIFEST_NAME_LENtManifestcBs"eZdZdded„Zed„ƒZd„Zed„ƒZ ed„ƒZ ed„ƒZ d„Z d„Z ed „ƒZed „ƒZed „ƒZed „ƒZed „ƒZd„Zeeed„Zed„ƒZed„ƒZed„ƒZed„ƒZd„ZRS(sThe Manifest interface represents a manifest in the AI server. Each specific manifest is associated with exactly one AI service. The following event types are possible for a Manifest: - ObjectChangedEvent - CreatedEvent - DeletedEvent cCs||_||_||_||_t|_t|_|djo|i|ƒ|_n|i |i ƒ|i i d|i ƒo#t titdƒ|i ƒ‚n|ttfjot titdƒƒ‚n|o||i _ntt|ƒitttgƒdS(sIThis method creates a new manifest for the service, initializing with the specified values. Parameters name: String Optional: This is the name to be given to the manifest, if no name is provided then the name will be extracted from the ai_instance tag's name attribute in the XML in the content. content: String This is the complete content of an XML manifest file, and will be validated against the service it's being added to. criteria: Criteria Object Optional: This is the Criteria used in selecting a manifest for use by a client. If omitted then the manifest will only be assigned to a client if it is set as the default for the service. default: Boolean Optional: Set this manifest as the default manifest for the service. Return Value None Errors / Exceptions AIServerError The following error types can be raised by this method: - ParsingError This error/exception will be raised should the provided manifest content fail to validate against the DTDs in the service. tfilter_by_namesDuplicated manifest name: '%s's!Default can only be True or FalseN(t_servicet_contentt_namet _criteriatFalset_criteria_fetchedt_pendingtNonetget_name_from_contentt validate_nametnametservicet get_manifestsRRtDUPLICATE_ENTRYt_tTruet INVALID_VALUEt_default_manifesttsuperRt__init__RRR(tselfRtcontentRtcriteriatdefault((s../manifest.pyR#0s(!          c Ksâttƒ||||}t|_|iƒtƒ}tƒ}||d<|i|d<||d<|i|d<|i|d<|i |dtnametag(RRR Rt isinstancet basestringRAtlenR R tdebugtAIdbt sanitize_sqlR<R=R>tsett ExceptionR(R5Rtroot((s../manifest.pyRÏs*     cCs |idƒS(s@Return True if the contents are from a derived manifest s#!(t startswith(R5R%((s../manifest.pyR;öscCsti|ƒodSytii|ƒ}Wn=tiij o+}tti t dƒt |ƒƒ‚nX|i dƒ}|djotti t dƒƒ‚ny|i dƒ}t |ƒ}Wn8tj o,ttit dƒ|idƒƒ‚nX|S(sExtracts and returns the manifest name from the XML content Parameters content: String This is the complete content of an XML manifest file. Return Value String The manifest name according to the attribute of the ai_instance tag. If no name attribute is found on a valid manifest or the contents are from a derived manifest, it will return None. Errors / Exceptions AIServerError The following error types can be raised by this method: - ParsingError This signifies that there was some issue with the XML, more information can be found in the error's reason field. sManifest Error: %st ai_instances,Manifest Error: No ai_instance tag was foundRsInvalid manifest name: '%s'sutf-8N(RR;RR<R=R>R?RRR@RRAtfindtgettUnicodeEncodeErrorR tencode(R5R%RQRGRSRt manifest_name((s../manifest.pyRüs&     c CsÛttƒ|iid|iƒp#ttitdƒ|iƒ‚nt ƒ}t ƒ}||d<|ii|d<|i|ds   F"