Re: [Zope-CMF] Accessing the "context"

2007-10-30 Thread Charlie Clark
Am 30.10.2007 um 18:13 schrieb robert rottermann: there are two places where you can put your code, in both cases acquisition is fully functional. Thanks very much! Now hit an error that my database connection object can't be pickled but at least I can access it! :-D Charlie -- Charlie Cl

Re: [Zope-CMF] Accessing the "context"

2007-10-30 Thread robert rottermann
Wichert Akkerman schrieb: > 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 w

Re: [Zope-CMF] Accessing the "context"

2007-10-30 Thread Wichert Akkerman
Previously Charlie Clark wrote: > > Am 30.10.2007 um 17:40 schrieb Wichert Akkerman: > > >__init__ is indeed the wrong place: when the instance is created it is > >not placed in an acquisition context yet. > > That would indeed explain things!!! Is it okay to call a method which > does this fr

Re: [Zope-CMF] Accessing the "context"

2007-10-30 Thread Charlie Clark
Am 30.10.2007 um 17:40 schrieb Wichert Akkerman: __init__ is indeed the wrong place: when the instance is created it is not placed in an acquisition context yet. That would indeed explain things!!! Is it okay to call a method which does this from __init__ ? def __init__(self, id):

Re: [Zope-CMF] Accessing the "context"

2007-10-30 Thread Wichert Akkerman
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

Re: [Zope-CMF] Accessing the "context"

2007-10-30 Thread Charlie Clark
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 getti

Re: [Zope-CMF] Accessing the "context"

2007-10-30 Thread Andrew Sawyers
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 everywhe

Re: [Zope-CMF] Accessing the "context"

2007-10-30 Thread Andrew Sawyers
Wichert Akkerman wrote: da = getattr('my_da_or_what_ever', context, None) getattr(context, 'my_da_or_what_ever', None) works a bit better. Note that getattr('foo', context, None) is wrong. Wichert has the correct syntax; I didn't even pay attention to the syntax originally. :) Do

Re: [Zope-CMF] Accessing the "context"

2007-10-30 Thread Charlie Clark
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

Re: [Zope-CMF] Accessing the "context"

2007-10-30 Thread Andrew Sawyers
Wichert Akkerman wrote: Previously Charlie Clark wrote: Am 30.10.2007 um 16:19 schrieb robert rottermann: da = getattr('my_da_or_what_ever', context, None) getattr(context, 'my_da_or_what_ever', None) works a bit better. Doesn't that only work within a PythonScript? I need

Re: [Zope-CMF] Accessing the "context"

2007-10-30 Thread Andrew Sawyers
Charlie Clark wrote: Am 30.10.2007 um 16:19 schrieb robert rottermann: da = getattr('my_da_or_what_ever', context, None) Doesn't that only work within a PythonScript? I need access from within a content type, ie. real Python code? That will work within your content class code as well. T

Re: [Zope-CMF] Accessing the "context"

2007-10-30 Thread Wichert Akkerman
Previously Charlie Clark wrote: > > Am 30.10.2007 um 16:19 schrieb robert rottermann: > > > > >da = getattr('my_da_or_what_ever', context, None) 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 conte

Re: [Zope-CMF] Accessing the "context"

2007-10-30 Thread Charlie Clark
Am 30.10.2007 um 16:19 schrieb robert rottermann: da = getattr('my_da_or_what_ever', context, None) Doesn't that only work within a PythonScript? I need access from within a content type, ie. real Python code? Charlie -- Charlie Clark Helmholtzstr. 20 Düsseldorf D- 40215 Tel: +49-211-93

Re: [Zope-CMF] Accessing the "context"

2007-10-30 Thread Charlie Clark
Am 30.10.2007 um 15:41 schrieb Andreas Jung: Dear all, a simple question with hopefully a simple answer! How do I access objects from an object's context or hierarchy? Acquisition? Traversal using restrictedTraverse()? Yes, but I'm not sure which. Say I have a DA, myDA, in my portal ro

Re: [Zope-CMF] Accessing the "context"

2007-10-30 Thread robert rottermann
Charlie Clark schrieb: > Dear all, > > a simple question with hopefully a simple answer! How do I access > objects from an object's context or hierarchy? Specifically I'd like to > be able to access a ZopeDA connection for a site. I > if you know the id of the object you are looking for beforeha

Re: [Zope-CMF] Accessing the "context"

2007-10-30 Thread Andreas Jung
--On 30. Oktober 2007 14:46:44 +0100 Charlie Clark <[EMAIL PROTECTED]> wrote: Dear all, a simple question with hopefully a simple answer! How do I access objects from an object's context or hierarchy? Acquisition? Traversal using restrictedTraverse()? -aj pgpXFZBCguPi5.pgp Description: