mò %á¸Ec@sØdZdkZdeifd„ƒYZdeifd„ƒYZdeifd„ƒYZdeefd „ƒYZd eifd „ƒYZd eifd „ƒYZdefd„ƒYZ deifd„ƒYZ dS(sF Transient Objects TransientObjectContainers are objects which contain zero or more TransientObjects. They implement the following interfaces: - ItemWithId - StringKeyedHomogenousItemContainer - TransientItemContainer In particular, one uses the 'new_or_existing' method on TransientObjectContainers to retrieve or create a TransientObject based on a given string key. If add or delete notifications are registered with the container, they will be called back when items in the container are added or deleted, with the item and the container as arguments. The callbacks may be registered either as bound methods, functions, or physical paths to Zope Script (Python Script or External Method) objects (e.g. '/some/resolvable/script/name'). In any of these cases, the delete and add notifications will be called with arguments allowing the callbacks to operate on data representing the state of the transient object at the moment of addition or deletion (see setAddNotificationTarget and setDelNotificationTarget below). TransientObjects are containerish items held within TransientObjectContainers and they implement the following interfaces: - ItemWithId - Transient - DictionaryLike - TTWDictionary - ImmutablyValuedMappingOfPickleableObjects Of particular importance is the idea that TransientObjects do not offer the contract of "normal" ZODB container objects; mutations made to items which are contained within a TransientObject cannot be expected to persist. Developers need explicitly resave the state of a subobject of a TransientObject by placing it back into the TransientObject via the TransientObject.__setitem__ or .set methods. This requirement is due to the desire to allow people to create alternate TransientObject implementations that are *not* based on the ZODB. Practically, this means that when working with a TransientObject which contains mutable subobjects (even if they inherit from Persistence.Persistent), you *must* resave them back into the TransientObject. For example:: class Foo(Persistence.Persistent): pass transient_object = transient_data_container.new('t') foo = transient_object['foo'] = Foo() foo.bar = 1 # the following is *necessary* to repersist the data transient_object['foo'] = foo Nt TransientcBsPtZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z RS( NcCsdS(sà Invalidate (expire) the transient object. Causes the transient object container's "before destruct" method related to this object to be called as a side effect. N((((tG/data/zmath/zope/lib/python/Products/Transience/TransienceInterfaces.pyt invalidatePscCsdS(s© Return true if transient object is still valid, false if not. A transient object is valid if its invalidate method has not been called. N((((RtisValidXscCsdS(sÿ Return the time the transient object was last accessed in integer seconds-since-the-epoch form. Last accessed time is defined as the last time the transient object's container "asked about" this transient object. N((((RtgetLastAccessed_scCsdS(s@ Cause the last accessed time to be set to now. N((((RtsetLastAccessedgscCsdS(sc Return the time the transient object was last modified in integer seconds-since-the-epoch form. Modification generally implies a call to one of the transient object's __setitem__ or __delitem__ methods, directly or indirectly as a result of a call to update, clear, or other mutating data access methods. N((((RtgetLastModifiedlscCsdS(s@ Cause the last modified time to be set to now. N((((RtsetLastModifieduscCsdS(ss Return the time the transient object was created in integer seconds-since-the-epoch form. N((((Rt getCreatedzscCsdS(s\ Return the key under which the object was placed in its container. N((((RtgetContainerKey€s( t__name__t __module__RRRRRRRR (((RROs      tDictionaryLikecBsJtZd„Zd„Zd„Zdd„Zd„Zd„Zd„ZRS( NcCsdS(s2 Return sequence of key elements. N((((Rtkeys‡scCsdS(s4 Return sequence of value elements. N((((RtvaluesŒscCsdS(s; Return sequence of (key, value) elements. N((((Rtitems‘stmarkercCsdS(sj Return value associated with key k. Return None or default if k does not exist. N((tktdefault((Rtget–scCsdS(sA Return true if item referenced by key k exists. N((R((Rthas_keyœscCsdS(s- Remove all key/value pairs. N((((Rtclear¡scCsdS(s4 Merge dictionary d into ourselves. N((td((Rtupdate¦s( R R R RRRRRR(((RR †s      t ItemWithIdcBstZd„ZRS(NcCsdS(sŸ Returns a meaningful unique id for the object. Note that this id need not the key under which the object is stored in its container. N((((RtgetId®s(R R R(((RR­st TTWDictionarycBs#tZd„Zd„Zd„ZRS(NcCsdS(s7 Call __setitem__ with key k, value v. N((Rtv((RtsetµscCsdS(s. Call __delitem__ with key k. N((R((RtdeleteºscCsdS(s7 Call __setitem__ with key k, value v. N((RR((Rt__guarded_setitem__¿s(R R RRR(((RR´s  t)ImmutablyValuedMappingOfPickleableObjectscBs#tZd„Zd„Zd„ZRS(NcCsdS(s€ Sets key k to value v, if k is both hashable and pickleable and v is pickleable, else raise TypeError. N((RR((Rt __setitem__ÅscCsdS(s‹ Returns the value associated with key k. Note that no guarantee is made to persist changes made to mutable objects obtained via __getitem__, even if they support the ZODB Persistence interface. In order to ensure that changes to mutable values are persisted, you need to explicitly put the value back in to the mapping via __setitem__. N((R((Rt __getitem__Ës cCsdS(s= Remove the key/value pair related to key k. N((R((Rt __delitem__Ös(R R R R!R"(((RRÄs  tHomogeneousItemContainercBs#tZdZed„Zd„ZRS(sÍ An object which: 1. Contains zero or more subobjects, all of the same type. 2. Is responsible for the creation of its subobjects. 3. Allows for the access of a subobject by key. cCsdS(só Return value associated with key k via __getitem__. If value associated with k does not exist, return default. Returned item is acquisition-wrapped in self unless a default is passed in and returned. N((RR((RRâscCsdS(sf Return true if container has value associated with key k, else return false. N((R((RRës(R R t__doc__tNoneRR(((RR#Ûs  t#StringKeyedHomogeneousItemContainercBstZd„Zd„ZRS(NcCsdS(s± Creates a new subobject of the type supported by this container with key "k" and returns it. If an object already exists in the container with key "k", a KeyError is raised. "k" must be a string, else a TypeError is raised. If the container is 'full', a MaxTransientObjectsExceeded exception will be raised. Returned object is acquisition-wrapped in self. N((R((RtnewòscCsdS(sÙ If an object already exists in the container with key "k", it is returned. Otherwise, create a new subobject of the type supported by this container with key "k" and return it. "k" must be a string, else a TypeError is raised. If a new object needs to be created and the container is 'full', a MaxTransientObjectsExceeded exception will be raised. Returned object is acquisition-wrapped in self. N((R((Rtnew_or_existings(R R R'R((((RR&ñs tTransientItemContainercBs>tZd„Zd„Zd„Zd„Zd„Zd„ZRS(NcCsdS(sn Set the number of minutes of inactivity allowable for subobjects before they expire. N((t timeout_mins((RtsetTimeoutMinutesscCsdS(sj Return the number of minutes allowed for subobject inactivity before expiration. N((((RtgetTimeoutMinutesscCsdS(sU Returns the currently registered 'add notification' value, or None. N((((RtgetAddNotificationTargetscCsdS(s@ Cause the 'add notification' function to be 'f'. If 'f' is not callable and is a string, treat it as a physical path to a Zope Script object (Python Script, External Method, et. al). 'add notify' functions need accept two arguments: 'item', which is the transient object being destroyed, and 'container', which is the transient object container which is performing the destruction. For example:: def addNotify(item, container): print "id of 'item' arg was %s" % item.getId() N((tf((RtsetAddNotificationTarget$scCsdS(s` Returns the currently registered 'delete notification' value, or None. N((((RtgetDelNotificationTarget5scCsdS(sK Cause the 'delete notification' function to be 'f'. If 'f' is not callable and is a string, treat it as a physical path to a Zope Script object (Python Script, External Method, et. al). 'Before destruction' functions need accept two arguments: 'item', which is the transient object being destroyed, and 'container', which is the transient object container which is performing the destruction. For example:: def delNotify(item, container): print "id of 'item' arg was %s" % item.getId() N((R.((RtsetDelNotificationTarget;s(R R R+R,R-R/R0R1(((RR)s      ( R$t InterfacetBaseRR RRRR#R&R)( RR R)R#RRRR2R&((Rt?Ks 7'!