Re: [Zope] Problem with __before_publishing_traverse__

2007-03-30 Thread Peter Bengtsson

Wow! You are amazing!
Yes, recreating the CookieCrumber just like it was before made it work.
Quirky I must admit.

Dieter Maurer wrote:

Peter Bengtsson wrote at 2007-3-28 10:40 +0100:

...
Removing the CookieCrumbler object obviously isn't a good enough 
solution because we need it for pretty logins. At the moment I don't 
understand how CookieCrumbler could have anything to do with it. It's 
stuff it does surrounding the REQUEST looks sane and I don't understand 
how it could effect my application.


A "CookieCumbler" is setting up itself as a (one of the)
"__before_publishing_traverse__" hook of its container.
Thus, it may cause problems from a __before_publishing_traverse__" call.

As you found out, it does not do so normally. Special (and rare) circumstances
are necessary.

It may be enough to recreate the "CookieCrumbler" instance.





--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Problem with __before_publishing_traverse__

2007-03-29 Thread Dieter Maurer
Peter Bengtsson wrote at 2007-3-28 10:40 +0100:
> ...
>Removing the CookieCrumbler object obviously isn't a good enough 
>solution because we need it for pretty logins. At the moment I don't 
>understand how CookieCrumbler could have anything to do with it. It's 
>stuff it does surrounding the REQUEST looks sane and I don't understand 
>how it could effect my application.

A "CookieCumbler" is setting up itself as a (one of the)
"__before_publishing_traverse__" hook of its container.
Thus, it may cause problems from a __before_publishing_traverse__" call.

As you found out, it does not do so normally. Special (and rare) circumstances
are necessary.

It may be enough to recreate the "CookieCrumbler" instance.



-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Problem with __before_publishing_traverse__

2007-03-28 Thread Peter Bengtsson

Sorry for late reply.
There is no Five in this environment. The "solution" was to remove the 
CookieCrumbler instance inside the MyApp instance. CookieCrumber (1.2) 
doesn't have a __before_publishing_traverse__ method but it does have 
this (CookieCrumbler.py:214)::


def __call__(self, container, req):
'''The __before_publishing_traverse__ hook.'''
resp = self.REQUEST['RESPONSE']
try:
attempt = self.modifyRequest(req, resp)
except CookieCrumblerDisabled:
return
if req.get('disable_cookie_login__', 0):
return
...more stuff I don't understand...


I tried setting up a similar environment (quickly) and a simple 
application that uses __before_publishing_traverse__() but could get it 
to stop working just because I put in a CookieCrumber instance :(


Removing the CookieCrumbler object obviously isn't a good enough 
solution because we need it for pretty logins. At the moment I don't 
understand how CookieCrumbler could have anything to do with it. It's 
stuff it does surrounding the REQUEST looks sane and I don't understand 
how it could effect my application.




Dieter Maurer wrote:

Peter Bengtsson wrote at 2007-3-23 13:29 +:

I have a product that looks like this::

class MyApp(Something):
  meta_type = 'x'
  def foobar(self):
  """ doc str """
  return "xxx"
  def __before_publishing_traverse__(self, object, request=None):
  print "HOUSTON"
...
When I view objects of this class I'd expect Zope to call the 
__before_publishing_traverse__ hook and print HOUSTON, but it doesn't :(

...
if object.__class__.__name__ == 'MyApp':
print object.foobar()
print object.foobar
print object.__before_publishing_traverse__(object, self)
print bpth
 path = request.path = request['TraversalRequestNameStack']



When I look at the output of this I get:

xxx
>
None


Maybe, instead of "foobar", you should print "__before_publishing_traverse__".

  "Five" started to fiddle around with "__before_publishing_traverse__"
  (to make Zope 3 traversal available) and maybe this introduced
  the bug no longer to call the existing "__before_publishing_traverse__"?





--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Problem with __before_publishing_traverse__

2007-03-23 Thread Dieter Maurer
Peter Bengtsson wrote at 2007-3-23 13:29 +:
>I have a product that looks like this::
>
>class MyApp(Something):
>   meta_type = 'x'
>   def foobar(self):
>   """ doc str """
>   return "xxx"
>   def __before_publishing_traverse__(self, object, request=None):
>   print "HOUSTON"
> ...
>When I view objects of this class I'd expect Zope to call the 
>__before_publishing_traverse__ hook and print HOUSTON, but it doesn't :(
> ...
> if object.__class__.__name__ == 'MyApp':
> print object.foobar()
> print object.foobar
> print object.__before_publishing_traverse__(object, self)
> print bpth
>  path = request.path = request['TraversalRequestNameStack']
>
>
>
>When I look at the output of this I get:
>
>xxx
>>
>None

Maybe, instead of "foobar", you should print "__before_publishing_traverse__".

  "Five" started to fiddle around with "__before_publishing_traverse__"
  (to make Zope 3 traversal available) and maybe this introduced
  the bug no longer to call the existing "__before_publishing_traverse__"?



-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Problem with __before_publishing_traverse__

2007-03-23 Thread Peter Bengtsson

I have a product that looks like this::

class MyApp(Something):
  meta_type = 'x'
  def foobar(self):
  """ doc str """
  return "xxx"
  def __before_publishing_traverse__(self, object, request=None):
  print "HOUSTON"

  index_html = PageTemplateFile(...)

When I view objects of this class I'd expect Zope to call the 
__before_publishing_traverse__ hook and print HOUSTON, but it doesn't :(



I started fiddling with 
/usr/lib/zope-2.8.8/lib/python/ZPublisher/BaseRequest.py to try to see 
what's going on. BEFORE (around line 269)::


while 1:
bpth = getattr(object, '__before_publishing_traverse__', None)
if bpth is not None:
bpth(object, self)
path = request.path = request['TraversalRequestNameStack']

AFTER::


while 1:
bpth = getattr(object, '__before_publishing_traverse__', None)
if bpth is not None:
bpth(object, self)
if object.__class__.__name__ == 'MyApp':
print object.foobar()
print object.foobar
print object.__before_publishing_traverse__(object, self)
print bpth
 path = request.path = request['TraversalRequestNameStack']



When I look at the output of this I get:

xxx
>
None


This is on Zope 2.8.8 and I've never had problems with 
__before_publishing_traverse__ in Zope 2.8's before.

Could it be that something in Zope 2.8.8 has changed?

--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )