Re: [Zope] Aquisition

2005-08-12 Thread Timur Izhbulatov
Date: Fri, 12 Aug 2005 10:48:44 +0400
From: Timur Izhbulatov [EMAIL PROTECTED]
To: Dieter Maurer [EMAIL PROTECTED]
Subject: Re: [Zope] Aquisition

No, I don't forget to set the id. All objects which my product contains do have
an id:
# in __init__
self._setObject(add.id, add)
self._setObject(search.id, search)
self._setObject(conn.id, conn)
WARN(add.id: %s % add.id)
WARN(search.id: %s % search.id)
WARN(conn.id: %s % conn.id)

 app.inventory.id
'inventory'
 app.inventory.add.id
'add'
 app.inventory.search.id
'search'
 app.inventory['db-connection'].id
'db-connection'

Also I can see it in the log file:

2005-08-12T10:31:17 PROBLEM(100) Inventory add.id: add
--
2005-08-12T10:31:17 PROBLEM(100) Inventory search.id: search
--
2005-08-12T10:31:17 PROBLEM(100) Inventory conn.id: db-connection


But the connection still can only be found if it's in the root folder. That's
really weird.

On Thu, Aug 11, 2005 at 08:25:22PM +0200, Dieter Maurer wrote:
 Timur Izhbulatov wrote at 2005-8-11 12:16 +0400:
  ...
 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 code of SQLConnectionIDs looks like this:
 
 ...
 for o in self.objectValues():
 if (hasattr(o,'_isAnSQLConnection') and o._isAnSQLConnection
 and hasattr(o,'id')):
 
 Thus, a candidate SQLConnection must have an id.
 
 Now, when you create an object programmatically, it is quite
 easy to forget to give it an id (specifying the id in _setObject
 is not enough; the object itself must contain the id redundantly).
 
 
 -- 
 Dieter

-- 
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:[EMAIL PROTECTED]
Building Successful Supply Chains - One Solution At A Time.
www.oilspace.com
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Aquisition

2005-08-11 Thread Timur Izhbulatov

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:[EMAIL PROTECTED]
Building Successful Supply Chains - One Solution At A Time.
www.oilspace.com
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )