Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
3

ÒƜeW.ã@s8dZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddl
m
ZddlZddlm
Z
ddlmZddlmZddlmZGd	d
„d
ejƒZGdd„deƒZGd
d„dejƒZejZejZejZejZ Gdd„dejƒZ dd„Z!Gdd„dej"ƒZ#Gdd„dej$ƒZ$dd„Z%dd„Z&ddd„Z'dS)z$Contego common internal object modeléN)Úversionutils)Úbase)Ú	exception)Úobjects)Úfields)Úutilsc@s0eZdZgZdd„Zedd„ƒZedd„ƒZdS)ÚContegoObjectRegistrycCs^tj|jƒ}tt|jƒƒs,tt|jƒ|ƒn.tjtt|jƒƒjƒ}||krZtt|jƒ|ƒdS)N)rZconvert_version_to_tupleÚVERSIONÚhasattrrÚobj_nameÚsetattrÚgetattr)ÚselfÚclsÚindexÚversionZcur_version©rú/usr/lib/python3.6/base.pyÚregistration_hooksz'ContegoObjectRegistry.registration_hookcCs|jdƒ|ƒ|jj|ƒ|S)zµRegister a class as notification.
        Use only to register concrete notification or payload classes,
        do not register base classes intended for inheritance only.
        F)Zregister_ifÚnotification_classesÚappend)rÚnotification_clsrrrÚregister_notification'sz+ContegoObjectRegistry.register_notificationcCsx|jD]}|j|ƒqWdS)z²Register previously decorated notification as normal ovos.
        This is not intended for production use but only for testing and
        document generation purposes.
        N)rÚregister)rrrrrÚregister_notification_objects1sz3ContegoObjectRegistry.register_notification_objectsN)Ú__name__Ú
__module__Ú__qualname__rrÚclassmethodrrrrrrrs

rc@s>eZdZdZejddejddejddejdddœZdS)ÚContegoPersistentObjectzuMixin class for Persistent objects.

    This adds the fields that we use in common for most persistent objects.
    T)ZnullableF)Údefault)Z
created_atZ
updated_atZ
deleted_atZdeletedN)rrrÚ__doc__Ú
obj_fieldsZ
DateTimeFieldZBooleanFieldrrrrrr:s



rc@s@eZdZdZdZdZedd„ƒZej	dd„ƒZ
ej	dd	„ƒZd
S)Ú
ContegoObjecta\Base class and object factory.

    This forms the base of all objects that can be remoted or instantiated
    via RPC. Simply defining a class that inherits from this base class
    will make it remotely instantiatable. Objects should implement the
    necessary "get" classmethod routines as well as "save" object methods
    as appropriate.
    Zcontego_objectÚcontegocCs
tƒ‚dS)zÊA check that can be used to inhibit online migration behavior

        This is usually used to check if all services that will be accessing
        the db directly are ready for the new format.
        N)ÚNotImplementedErrorrrrrÚshould_migrate_dataSsz!ContegoObject.should_migrate_dataccs$|j}||_z
dVWd||_XdS)N)Ú_context)rÚcontextÚoriginal_contextrrrÚobj_alternate_context\s

z#ContegoObject.obj_alternate_contextccsF|jdkrtjd|jƒd‚|j}|jjƒ|_z
dVWd||_XdS)aContext manager to make an object call as an admin.

        This temporarily modifies the context embedded in an object to
        be elevated() and restores it after the call completes. Example
        usage:

           with obj.obj_as_admin():
               obj.save()

        NÚobj_as_admin)ÚmethodZobjtype)r'rZOrphanedObjectErrorrZelevated)rr)rrrr+fs

zContegoObject.obj_as_adminN)rrrr!ZOBJ_SERIAL_NAMESPACEZOBJ_PROJECT_NAMESPACEÚstaticmethodr&Ú
contextlibÚcontextmanagerr*r+rrrrr#Fs	
r#c@seZdZdd„Zdd„ZdS)ÚContegoObjectDictCompatccs.x(|jD]}|j|ƒs ||jkr|VqWdS)N)r"Zobj_attr_is_setZobj_extra_fields)rÚnamerrrÚ__iter__‚s

z ContegoObjectDictCompat.__iter__cCst|ƒS)N)Úlist)rrrrÚkeysˆszContegoObjectDictCompat.keysN)rrrr2r4rrrrr0sr0cCsd|S)z>Return the mangled name of the attribute's underlying storage.Z_obj_r)r1rrrÚget_attrname‹sr5c@s0eZdZdZdd„Zdd„Zdd„Zdd	„Zd
S)ÚContegoObjectSerializeraDA ContegoObject-aware Serializer.

    This implements the Oslo Serializer interface and provides the
    ability to serialize and deserialize ContegoObject entities. Any service
    that needs to accept or return ContegoObjects as arguments or result values
    should pass this to its RPCClient and RPCServer objects.
    cCsšytj||d}Wn‚tjk
r”|d}|jdƒdkrbdj|jdƒdd…ƒ|d<|j||ƒS|d}tj	|ƒ}||krŽ|j
j|||ƒ}n‚YnX|S)N)r(zcontego_object.versionÚ.ézcontego_object.name)r#Zobj_from_primitiveÚovoo_excZIncompatibleObjectVersionÚcountÚjoinÚsplitÚ_process_objectÚ	ovoo_baseZobj_tree_get_versionsZ	conductorZobject_backport_versions)rr(ZobjprimZobjinstZobjverZobjnameZversion_manifestrrrr=œs
z'ContegoObjectSerializer._process_objectcsZ|j}t|tƒr2|f‡‡fdd„t|jƒƒDƒŽS|tkr>t}|‡‡fdd„|DƒƒSdS)aoProcess an iterable, taking an action on each value.
        :param:context: Request context
        :param:action_fn: Action to take on each item in values
        :param:values: Iterable container of things to take action on
        :returns: A new container of the same type (except set) with
                  items from values having had action applied.
        csi|]\}}ˆˆ|ƒ|“qSrr)Ú.0ÚkÚv)Ú	action_fnr(rrú
<dictcomp>ºsz=ContegoObjectSerializer._process_iterable.<locals>.<dictcomp>csg|]}ˆˆ|ƒ‘qSrr)r?Úvalue)rBr(rrú
<listcomp>Äsz=ContegoObjectSerializer._process_iterable.<locals>.<listcomp>N)Ú	__class__Ú
issubclassÚdictr3ÚitemsÚset)rr(rBÚvaluesÚiterabler)rBr(rÚ_process_iterable°s
z)ContegoObjectSerializer._process_iterablecCsDt|dƒrt|jƒr|jƒ}n"t|ttttfƒr@|j||j	|ƒ}|S)NÚobj_to_primitive)
r
ÚcallablerNÚ
isinstanceÚtupler3rJrHrMÚserialize_entity)rr(ÚentityrrrrRÆs



z(ContegoObjectSerializer.serialize_entitycCsFt|tƒr d|kr |j||ƒ}n"t|ttttfƒrB|j||j|ƒ}|S)Nzcontego_object.name)rPrHr=rQr3rJrMÚdeserialize_entity)rr(rSrrrrTÏs
z*ContegoObjectSerializer.deserialize_entityN)rrrr!r=rMrRrTrrrrr6“s
	r6c@s*eZdZedd„ƒZeejfdd„ƒZdS)ÚObjectListBasecCsd|S)Nzcontego_object.%sr)rÚfieldrrrÚ_obj_primitive_keyÚsz!ObjectListBase._obj_primitive_keycCs,|j|ƒ}|tjkr||S|j||ƒSdS)N)rWr"ÚUnspecifiedDefaultÚget)rZ	primitiverVr ÚkeyrrrÚ_obj_primitive_fieldÞs

z#ObjectListBase._obj_primitive_fieldN)rrrrrWr"rXr[rrrrrU×srUcCspi}xB|D]:}t||ƒ}||kr4|ƒ||<g||_||jj|ƒq
Wx"|D]}|||_||jƒqNW|S)a Construct a dictionary of object lists, keyed by item_key.

    :param:context: Request context
    :param:list_cls: The ObjectListBase class
    :param:obj_list: The list of objects to place in the dictionary
    :param:item_key: The object attribute name to use as a dictionary key
    )r
rrr'Zobj_reset_changes)r(Zlist_clsZobj_listZitem_keyZ	obj_listsÚobjrZrrrÚobj_make_dict_of_listsçs	





r]cs@‡fdd„}tˆddƒ|_ˆ|_tˆdƒr8tjˆƒ|ƒSt|ƒS)zCDecorator that will do the arguments serialization before remoting.csºdd„|Dƒ}x~t|jƒƒD]n\}}|dkr@|r@tj|ƒ||<q|dkrp|rpt|tjƒrpdjtj|ƒƒ||<qt|t	j	ƒrt
j|ƒ||<qWtˆdƒr¨ˆ|f|ž|ŽSˆj
d|ƒ||ŽS)NcSs&g|]}t|tjƒrtj|ƒn|‘qSr)rPÚdatetimerÚstrtime)r?ÚargrrrrEsz3serialize_args.<locals>.wrapper.<locals>.<listcomp>Zexc_valZexc_tbÚÚ__call__)r3rIÚsixZ	text_typerPZstring_typesr;Ú	tracebackÚ	format_tbr^rr_r
Ú__get__)r\ÚargsÚkwargsr@rA)ÚfnrrÚwrapperÿs
zserialize_args.<locals>.wrapperÚ	remotableFrb)r
rkZoriginal_fnr
Ú	functoolsÚwrapsr)rirjr)rirÚserialize_argsýs
rncsJ‡fdd„‰|dk	r dg|}ndg}ˆ|jƒ|ƒ}ˆ|jƒ|ƒ}||kS)aDCompare two primitives for equivalence ignoring some keys.

    This operation tests the primitives of two objects for equivalence.
    Object primitives may contain a list identifying fields that have been
    changed - this is ignored in the comparison. The ignore parameter lists
    any other keys to be ignored.

    :param:obj1: The first object in the comparison
    :param:obj2: The second object in the comparison
    :param:ignore: A list of fields to ignore
    :returns: True if the primitives are equal ignoring changes
    and specified fields, otherwise False.
    csjt|tƒrDx|D]}|j|dƒqWxt|jƒƒD]}ˆ||ƒq2Wt|tƒrfx|D]}ˆ||ƒqTW|S)N)rPrHÚpopr3rK)Zprimr4r@rA)Ú_striprrrp$s



zobj_equal_prims.<locals>._stripNzcontego_object.changes)rN)Zobj_1Zobj_2Úignorer4Zprim_1Zprim_2r)rprÚobj_equal_primssrr)N)(r!r.r^rlrdZnetaddrZoslo_messagingZ	messagingZ
oslo_utilsrZoslo_versionedobjectsrr>rr9rcr$rZcontego.objectsrr"rZVersionedObjectRegistryrÚobjectrZVersionedObjectr#Zremotable_classmethodrkZ
obj_make_listZVersionedObjectDictCompatr0r5ZNoOpSerializerr6rUr]rnrrrrrrÚ<module>s8#7
D