Previously Charlie Clark wrote: > > Am 30.10.2007 um 17:04 schrieb Andrew Sawyers: > > >If it's in a content type's class, why not: > >id = getattr(self, 'da_id', None) > >Just using self as the context should be fine. > >-- that of course presumes that the type is wrapped properly when > >you call that within your method. > > mm, currently getting None back so I guess I'm not wrapping things > properly. > > This is a skeleton bit of code: > > class ContentType(PortalContent): > """A content type with access to an external database""" > > def __init__(self, id): > self.id = id > DA = getattr(self, 'MyDA', None) > #self.conn = DA() # not working at the moment because DA is None > > Is it wrong to try and do this in my __init__ ? Regarding your other > suggestion: yes, I probably will factor this out into a utility once > I've worked out how to access the DA!!!
__init__ is indeed the wrong place: when the instance is created it is not placed in an acquisition context yet. Wichert. -- Wichert Akkerman <[EMAIL PROTECTED]> It is simple to make things. http://www.wiggy.net/ It is hard to make things simple. _______________________________________________ Zope-CMF maillist - Zope-CMF@lists.zope.org http://mail.zope.org/mailman/listinfo/zope-cmf See http://collector.zope.org/CMF for bug reports and feature requests