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:
a

[r`e¿-ã@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^t |j¡}tt| ¡ƒs,tt| ¡|ƒn.t tt| ¡ƒj¡}||krZtt| ¡|ƒdS©N)rZconvert_version_to_tupleZVERSIONÚhasattrrÚobj_nameÚsetattrÚgetattr)ÚselfÚclsÚindexÚversionZcur_version©rú6/usr/lib/python3.9/site-packages/dmapi/objects/base.pyÚregistration_hooksÿz'ContegoObjectRegistry.registration_hookcCs| d¡|ƒ|j |¡|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©rZnotification_clsrrrÚregister_notification'sz+ContegoObjectRegistry.register_notificationcCs|jD]}| |¡qdS)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ÚregisterrrrrÚ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.
    Zdmapi_objectÚdmapicCs
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}||_zdVW||_n||_0dSr	)Ú_context)rÚcontextÚoriginal_contextrrrÚobj_alternate_context\s
z#ContegoObject.obj_alternate_contextccsL|jdurtjd| ¡d‚|j}|j ¡|_zdVW||_n||_0dS)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*|jD]}| |¡s||jvr|VqdSr	)r"Zobj_attr_is_setZobj_extra_fields)rÚnamerrrÚ__iter__‚s


ÿz ContegoObjectDictCompat.__iter__cCst|ƒSr	)Ú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œztj||d}Wn„tjy–|d}| d¡dkrdd | d¡dd…¡|d<| ||¡YS|d}t 	|¡}||vr|j
 |||¡}n‚Yn0|S)N)r(znova_object.versionÚ.éúnova_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_objectcs^|j}t|tƒr6|fi‡‡fdd„t| ¡ƒDƒ¤ŽS|tkrBt}|‡‡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>ºsÿz=ContegoObjectSerializer._process_iterable.<locals>.<dictcomp>csg|]}ˆˆ|ƒ‘qSrr)r@ÚvaluerCrrÚ
<listcomp>Äóz=ContegoObjectSerializer._process_iterable.<locals>.<listcomp>N)Ú	__class__Ú
issubclassÚdictr3ÚitemsÚset)rr(rDÚvaluesÚiterablerrCrÚ_process_iterable°s

ÿ
z)ContegoObjectSerializer._process_iterablecCsDt|ttttfƒr$| ||j|¡}nt|dƒr@t|j	ƒr@| 	¡}|S)NÚobj_to_primitive)
Ú
isinstanceÚtupler3rMrKrPÚserialize_entityr
ÚcallablerQ©rr(ZentityrrrrTÆs
ÿ
ÿz(ContegoObjectSerializer.serialize_entitycCsFt|tƒr d|vr | ||¡}n"t|ttttfƒrB| ||j|¡}|S)Nr9)rRrKr>rSr3rMrPÚdeserialize_entityrVrrrrWÏs
ÿz*ContegoObjectSerializer.deserialize_entityN)rrrr!r>rPrTrWrrrrr6“s
	r6c@s*eZdZedd„ƒZeejfdd„ƒZdS)ÚObjectListBasecCsd|S)Nznova_object.%sr)rÚfieldrrrÚ_obj_primitive_keyØsz!ObjectListBase._obj_primitive_keycCs,| |¡}|tjkr||S| ||¡SdSr	)rZr"ÚUnspecifiedDefaultÚget)rZ	primitiverYr ÚkeyrrrÚ_obj_primitive_fieldÜs

z#ObjectListBase._obj_primitive_fieldN)rrrrrZr"r[r^rrrrrX×s

ÿrXcCshi}|D]:}t||ƒ}||vr2|ƒ||<g||_||j |¡q|D]}|||_|| ¡qH|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Úobjr]rrrÚobj_make_dict_of_listsås	



r`cs@‡fdd„}tˆddƒ|_ˆ|_tˆdƒr8t ˆ¡|ƒSt|ƒS)zCDecorator that will do the arguments serialization before remoting.cs¾dd„|Dƒ}t| ¡ƒD]l\}}|dkr>|r>t |¡||<q|dkrl|rlt|tjƒsld t |¡¡||<qt|t	j	ƒrt
 |¡||<qtˆdƒr¨ˆ|g|¢Ri|¤ŽSˆ 
d|¡|i|¤ŽS)NcSs&g|]}t|tjƒrt |¡n|‘qSr)rRÚdatetimerÚstrtime)r@ÚargrrrrGþsÿz3serialize_args.<locals>.wrapper.<locals>.<listcomp>Zexc_valZexc_tbÚÚ__call__)r3rLÚsixZ	text_typerRZstring_typesr<Ú	tracebackÚ	format_tbrarrbr
Ú__get__)r_ÚargsÚkwargsrArB©ÚfnrrÚwrapperýsÿ
zserialize_args.<locals>.wrapperÚ	remotableFre)r
roZoriginal_fnr
Ú	functoolsÚwrapsr)rmrnrrlrÚserialize_argsûsÿrrcsJ‡fdd„‰|dur dg|}ndg}ˆ| ¡|ƒ}ˆ| ¡|ƒ}||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.
    cs^t|tƒr<|D]}| |d¡qt| ¡ƒD]}ˆ||ƒq,t|tƒrZ|D]}ˆ||ƒqJ|Sr	)rRrKÚpopr3rN)Zprimr4rArB©Ú_striprrru"s

zobj_equal_prims.<locals>._stripNznova_object.changes)rQ)Zobj_1Zobj_2Úignorer4Zprim_1Zprim_2rrtrÚobj_equal_primssrw)N)(r!r.rarprgZnetaddrZoslo_messagingZ	messagingZ
oslo_utilsrZoslo_versionedobjectsrr?rr:rfr$rZ
dmapi.objectsrr"rZVersionedObjectRegistryrÚobjectrZVersionedObjectr#Zremotable_classmethodroZ
obj_make_listZVersionedObjectDictCompatr0r5ZNoOpSerializerr6rXr`rrrwrrrrÚ<module>s8#7
D