hi, while trying to figure out how to use Zope from Python I encountered the following problem. The first access to a dictionary shows me an empty one, while the next one produced the correct result (see dir(a.m)):
import sys sys.path.append('/home/oliver/Zope-2.1.6-src/lib/python') import Zope a = Zope.app() dir(a) ['Control_Panel', 'QuickStart', '__allow_groups__', '_objects', '_product_ac_permissions', '_product_meta_types', '_product_permissions', '_product_zclasses', 'acl_users', 'aq_order', 'copybases', 'footer', 'header', 'index_html', 'm', ... dir(a.m) [] dir(a.m) ['MySQL_database_connection', '_Access_contents_information_Permission', '_Add_Documents__Images__and_Files_Permission', '_Add_Folders_Permission', '_Change_DTML_Documents_Permission', '_Delete_objects_Permission', ....
could anyone explain why this is the case? thanks Oliver
Oliver Frommel wrote:
hi,
while trying to figure out how to use Zope from Python I encountered the following problem. The first access to a dictionary shows me an empty one, while the next one produced the correct result (see dir(a.m)):
import sys sys.path.append('/home/oliver/Zope-2.1.6-src/lib/python') import Zope a = Zope.app() dir(a) ['Control_Panel', 'QuickStart', '__allow_groups__', '_objects', '_product_ac_permissions', '_product_meta_types', '_product_permissions', '_product_zclasses', 'acl_users', 'aq_order', 'copybases', 'footer', 'header', 'index_html', 'm', ... dir(a.m) [] dir(a.m) ['MySQL_database_connection', '_Access_contents_information_Permission', '_Add_Documents__Images__and_Files_Permission', '_Add_Folders_Permission', '_Change_DTML_Documents_Permission', '_Delete_objects_Permission', ....
could anyone explain why this is the case?
I'll try... buts its a guess at best... i'd love to hear a better explanation. i think it has to do with the acquisition, traversal process, and the ZODB. i think to get to the object during the dir inspection you go through the traversal process which goes through the ZODB looking for the requested object. once it gets to the object the first time the object is loaded into memory (the object cache) and dir checks the object for its variables this triggers the acquisition process but dir exits with what it finds. the acquistion still happens and is cached somehow in the object cache so on the second dir inspection it finds all the acquired properties/variables of the object. if you had asked orig. for an acquired attribute you would have waited on the acquisition process to find it and return it or an attribute not found error. Cheers Kapil
participants (2)
-
Kapil Thangavelu -
Oliver Frommel