[Zope-CMF] Accessing the "context"

Charlie Clark charlie at begeistert.org
Tue Oct 30 12:38:32 EDT 2007


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!!!

Charlie

--
Charlie Clark
Helmholtzstr. 20
Düsseldorf
D- 40215
Tel: +49-211-938-5360
GSM: +49-178-782-6226





More information about the Zope-CMF mailing list