[Zope] Why doesn't this work?
Terry Hancock
hancock@anansispaceworks.com
Mon, 28 Jul 2003 22:58:14 -0700
On Monday 28 July 2003 08:01 pm, Dylan Reinhardt wrote:
> On Mon, 2003-07-28 at 19:05, Terry Hancock wrote:
> > On Monday 28 July 2003 02:41 pm, Dylan Reinhardt wrote:
> > > Globals.InitializeClass(MyContainer)
> >
> > Hey, that works!
>
> Glad to hear that helped. I didn't have a second guess.
:-)
Actually, though going to using __bobo_traverse__
introduces a bizarre new wrinkle to the problem. If you
access the object (in DTML) as:
Normal HTTP request (i.e. just put it in the HTML):
"""
<a href="MyContainer/Green">Link to Green wrapper
object.</a>
"""
that works (with __bobo_traverse__ defined).
And if you define an accessor method like the "get_obj"
method I defined, you can call the object using it:
"""
<dtml-var
expr="restrictedTraverse('MyContainer').get_obj('Green').index_html()"
>
"""
that works.
BUT
"""
<dtml-var
expr="restrictedTraverse('MyContainer/Green').index_html()"
>
"""
DOES NOT work!
You get the authentication failure, just as I did in the
case I posted earlier. This is with __bobo_traverse__ doing
basically the same thing that get_obj() did in my example
(you have to change the arguments around, because it
expects this calling profile:
def __bobo_traverse__(self, REQUEST=None, name=None):
"Traversal hook"
# your code here
return acquisition_wrapped_object
I can of course avoid calling it this way (it's not hard to
restrict myself to using restrictedTraverse on the "real"
object), but it is very weird. I remember from when I
first started poking around with this that I discovered
that restrictedTraverse uses a "fake request", and I now
think that must be at the heart of the matter. But I still
don't understand it.
I had been thinking that it was ultimately because of the
problem of returning the dynamically created wrapper
object, which is why I wrote the PBTest product to separate
that problem out. But apparently that's not it, since
(after applying your help) that part works okay.
Any thoughts on this?
Cheers,
Terry
--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks http://www.anansispaceworks.com