[Zope-CMF] Accessing the "context"

Andrew Sawyers andrew at sawdog.com
Tue Oct 30 12:04:29 EDT 2007


Charlie Clark wrote:
>
> Am 30.10.2007 um 16:53 schrieb Wichert Akkerman:
>
>> getattr(context, 'my_da_or_what_ever', None) works a bit better.
>>
>>> Doesn't that only work within a PythonScript? I need access from
>>> within a content type, ie. real Python code?
>>
>> It's called acquisition and it works everywhere. Try it.
>
> Yes, but the context isn't available everywhere. How do I get hold of 
> that?
>
> Charlie
> -- 
> Charlie Clark
> Helmholtzstr. 20
> Düsseldorf
> D- 40215
> Tel: +49-211-938-5360
> GSM: +49-178-782-6226
>
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.

Andrew


More information about the Zope-CMF mailing list