[Grok-dev] how should we compute URLs for transient objects?
Brandon Craig Rhodes
brandon at rhodesmill.org
Thu Sep 6 23:44:58 EDT 2007
Kevin Teague <kevin at bud.ca> writes:
>> class PersonLocation(grok.Adapter):
>> grok.context(Person) # or "IPerson", if one gets fancy
>> grok.provides(ILocation)
>> def __init__(self, context):
>> self.__parent__ = PersonContainer()
>> self.__name__ = str(context.id)
>
> This example is close to working, but __parent__ *must* be a
> reference to an object in the containment heirarchy.
Yes, I caught that problem before posting it, but since Zope ignores
the adapter anyway, it didn't seem worth fixing yet. :-) First I need
to understand whether AbsoluteURL's failure to adapt its context to
ILocation is a bug, or something I don't understand about the whole
Zope approach to things (I hope very much that it's the former, and,
if so, am willing to submit a patch myself).
> self.__parent__ = grok.getSite()['people']
Wow! I didn't know Grok had a "getSite()" method! That's exactly
what I needed last night when, after patching my own version of
AbsoluteURL, I never could find a way for my Adapter to reference the
site itself.
I have just tried your suggestion, and it works perfectly. Thank you
for your help!
--
Brandon Craig Rhodes brandon at rhodesmill.org http://rhodesmill.org/brandon
More information about the Grok-dev
mailing list