[Zope] Product initilization, acquisition and instance refere nces
Jean-Francois.Doyon at CCRS.NRCan.gc.ca
Jean-Francois.Doyon at CCRS.NRCan.gc.ca
Thu Sep 11 10:31:47 EDT 2003
Dylan,
Most definitely ! Here's the relevant code:
from Globals import Persistent, DTMLFile, InitializeClass
from AccessControl.Role import RoleManager
from AccessControl import ClassSecurityInfo
from Acquisition import Implicit
from OFS import SimpleItem
from ogclib.WFS import GETQuery <--- My python module
def addWFSGETQuery(self, id, connection, typename, title='',
propertyname='', featureversion='', maxfeatures='', featureid='', filter='',
bbox='', REQUEST=None):
""" Add a WFS GET Query object """
self._setObject( id, WFSGETQuery(id, connection, typename, title,
propertyname, featureversion, maxfeatures, featureid, filter, bbox ) )
if REQUEST is not None:
REQUEST['RESPONSE'].redirect(self.absolute_url()+'/manage_main')
class WFSGETQuery( GETQuery, SimpleItem.Item, Persistent, Implicit,
RoleManager ): <- The Zope wrapper for my module
def __init__( self, id, connection, typename, title='',
propertyname='', featureversion='', maxfeatures='', featureid='', filter='',
bbox='' ):
self.id = id
self.edit( connection, typename, title, propertyname,
featureversion, maxfeatures, featureid, filter, bbox )
security.declareProtected( 'Change Database Methods' , 'edit' )
def edit(self, connection, typename, title='', propertyname='',
featureversion='', maxfeatures='', featureid='', filter='', bbox='' ):
self.connection = connection
self.typename = typename
self.title = title
self.propertyname = propertyname
self.featureversion = featureversion
self.maxfeatures = maxfeatures
self.featureid = featureid
self.filter = filter
self.bbox = bbox
self._cleanupparams() <--- provided by GETQuery
# Get feature type information and validate
self._getfeaturetypeinfo() <--- Provided by GETQuery
The problem is that outside of zope "connection" is an instance of another
class ("Connection") ... _getfeatureinfo() which is called by edit which is
called by __init__ needs that instance in order to do some work. But I can't
get that instance because getattr doesn't find it !! (Even though it is
there, in the same folder, available to be acquired)
The strange thing is that before I wrote the classes into python modules, I
had the whole thing as pure Zope products, and everythng was working fine.
then I split it into two in order to have the functionality as regular
Python modules, and when I come back into Zope, the same thing no longer
works ?
Thanks,
J.F.
-----Original Message-----
From: Dylan Reinhardt [mailto:zope at dylanreinhardt.com]
Sent: Wednesday, September 10, 2003 4:27 PM
To: Jean-Francois.Doyon at ccrs.nrcan.gc.ca
Cc: Zope Users
Subject: Re: [Zope] Product initilization, acquisition and instance
references
On Wed, 2003-09-10 at 12:49, Jean-Francois.Doyon at CCRS.NRCan.gc.ca wrote:
> The problem is the second one, which uses the first one. First of all, it
> looks like while the class is being instanciated, there isn't any
> acquisition yet ?
Did you use the Acquisition.Implicit mixin when you defined the class?
HTH,
Dylan
More information about the Zope
mailing list