[Zope] Aquisition
Timur Izhbulatov
timur at oilspace.com
Thu Aug 11 04:16:28 EDT 2005
Hi All,
Sorry for long message.
I have a simple Zope product which is an ObjectManager descendant and contains a
database connection and a ZSQL method. It creates these objects during its
initialisation.
>>> app.inventory
<Inventory instance at b7300f20>
>>> app.inventory['db-connection']
<Connection instance at b724a980>
>>> app.inventory.list
<SQL instance at b724a8f0>
Everything is OK except one thing. A problem appears when I go to the
manage_main page of the ZSQL method. It can't find any database connection using
the SQLConnectionsIDs function from the
${ZOPE_HOME}/lib/python/Products/ZSQLMethods/SQL.py module.
The function is called from
${ZOPE_HOME}/lib/python/Products/ZSQLMethods/dtml/edit.dtml
To investigate the problem I have added some debugging output statements to this
function:
def SQLConnectionIDs(self):
"""Find SQL database connections in the current folder and above
This function return a list of ids.
"""
ids={}
have_id=ids.has_key
StringType=type('')
LOG('ZSQL', INFO, 'self.aq_chain: %s' % self.aq_chain)
LOG('ZSQL', INFO, 'self.id: "%s"' % self.id)
while self is not None:
if hasattr(self, 'objectValues'):
for o in self.objectValues():
try:
LOG('ZSQL', INFO, 'o.id: %s' % (o.id()))
except:
LOG('ZSQL', INFO, 'o.id: %s' % (o.id))
if (hasattr(o,'_isAnSQLConnection') and o._isAnSQLConnection
and hasattr(o,'id')):
id=o.id
if type(id) is not StringType: id=id()
if not have_id(id):
if hasattr(o,'title_and_id'): o=o.title_and_id()
else: o=id
ids[id]=id
if hasattr(self, 'aq_parent'): self=self.aq_parent
else: self=None
ids=[ (item[1], item[0]) for item in ids.items() ]
ids.sort()
LOG('ZSQL', INFO, 'ids: %s' % (ids))
return ids
The output shows that SQLConnectionsIDs is called in wrong context.
2005-08-11T10:57:31 INFO(0) ZSQL self.aq_chain: [<Application instance at b73483b0>, <RequestContainer instance at b767ccb0>]
------
2005-08-11T10:57:31 INFO(0) ZSQL self.id: "<bound method Application.id of <Application instance at b73483b0>>"
------
2005-08-11T10:57:31 INFO(0) ZSQL o.id: acl_users
------
2005-08-11T10:57:31 INFO(0) ZSQL o.id: Control_Panel
------
2005-08-11T10:57:31 INFO(0) ZSQL o.id: temp_folder
------
2005-08-11T10:57:31 INFO(0) ZSQL o.id: session_data_manager
------
2005-08-11T10:57:31 INFO(0) ZSQL o.id: browser_id_manager
------
2005-08-11T10:57:31 INFO(0) ZSQL o.id: error_log
------
2005-08-11T10:57:31 INFO(0) ZSQL o.id: standard_error_message
------
2005-08-11T10:57:31 INFO(0) ZSQL o.id: standard_template.pt
------
2005-08-11T10:57:31 INFO(0) ZSQL o.id: index_html
------
2005-08-11T10:57:31 INFO(0) ZSQL o.id: standard_html_header
------
2005-08-11T10:57:31 INFO(0) ZSQL o.id: standard_html_footer
------
2005-08-11T10:57:31 INFO(0) ZSQL o.id: virtual_hosting
------
2005-08-11T10:57:31 INFO(0) ZSQL o.id: inventory
------
2005-08-11T10:57:31 INFO(0) ZSQL ids: []
Any help is greatly appreciated.
Thanks,
--
Timur Izhbulatov
OILspace, 26 Leninskaya sloboda, bld. 2, 2nd floor, 115280 Moscow, Russia
P:+7 095 105 7245 + ext.205 F:+7 095 105 7246 E:TimurIzhbulatov at oilspace.com
Building Successful Supply Chains - One Solution At A Time.
www.oilspace.com
More information about the Zope
mailing list