Re: [Zope3-Users] Help: I cannot login after installing z3c.formjs

2008-07-17 Thread kevin gill
Thanks for the analysis. I did some digging and found that it was entirely
my own fault. I have some code in the SessionCredentials object which
stores the request annotations. I do this to handle extra information on
the login form, e.g. login groups.


 Hmm, I've never gotten an error like that.  It probably wouldn't be
 too difficult to patch jsclientevent.py by making sure caught events
 have security proxies removed before they are stored.  But I wonder
 why any request related data is being stored in the database.  My
 understanding is that session data gets stored in the database but is
 totally separate from the request.  A cookie (stored in the request)
 is used to lookup the session data from the database.  My gut instinct
 is that there is something wrong with the credentials plugin you are
 using because request annotations should never be persisted across
 multiple requests.  I am using SessionCredentials myself without any
 problems.  Can you find the code path that tries to store the request
 annotation?

 From a z3c.formjs perspective, if you want the caught events to not be
 security proxied, you could create another object event listener (like
 the one in z3c/formjs/jsclientevent.py) that goes through the caught
 events and removes security proxies.  In the end this is a fragile
 solution because you can't guarantee the order in which events are
 handled, and unfortunately the way the zcml configuration is split up
 (not at all), it would be difficult to override this default event
 handler using an exclude directive.

 I'm currently making some improvements to z3c.formjs and will make
 sure to split up the zcml files more so doing such a customization is
 easier.  There should be new releases of z3c.form and z3c.formjs in
 the next couple of weeks with these changes.

I will be interested in seeing where you are going with formjs. I am
really using it to get the AjaxRequestHandler at the moment.

Thanks

Kevin


 - Paul

 On Tue, Jul 15, 2008 at 7:51 AM, kevin gill [EMAIL PROTECTED] wrote:
 Hi,

 I am integrating z3c.formjs to a new site. After installing z3c.formjs I
 can no longer login. If I remove it, I can login again.

 It causes a problem with the SessionCredentials mechanism that I am
 using.
 The SessionCredentials annotations now contains event handlers of type
 z3c.formjs.jsclientevent.caughtEvents. These cannot be pickled.

 I tried both the PersisentSessionDataContainer and the RamSessionData
 Container.

 Does anyone have suggestions on how I might proceed with this?

 Thanks,

 Kevin


 This is the tail of the exception

 2008-07-15T15:31:38 ERROR SiteError rm.commit(self)
 --
 2008-07-15T15:31:38 ERROR SiteError   File
 /opt/zope3-eggs/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/Connection.py,
 line 541, in commit
 --
 2008-07-15T15:31:38 ERROR SiteError self._commit(transaction)
 --
 2008-07-15T15:31:38 ERROR SiteError   File
 /opt/zope3-eggs/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/Connection.py,
 line 586, in _commit
 --
 2008-07-15T15:31:38 ERROR SiteError
 self._store_objects(ObjectWriter(obj), transaction)
 --
 2008-07-15T15:31:38 ERROR SiteError   File
 /opt/zope3-eggs/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/Connection.py,
 line 613, in _store_objects
 --
 2008-07-15T15:31:38 ERROR SiteError p = writer.serialize(obj)  #
 This
 calls __getstate__ of obj
 --
 2008-07-15T15:31:38 ERROR SiteError   File
 /opt/zope3-eggs/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/serialize.py,
 line 408, in serialize
 --
 2008-07-15T15:31:38 ERROR SiteError return self._dump(meta,
 obj.__getstate__())
 --
 2008-07-15T15:31:38 ERROR SiteError   File
 /opt/zope3-eggs/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/serialize.py,
 line 420, in _dump
 --
 2008-07-15T15:31:38 ERROR SiteError self._p.dump(state)



 I investigated the offending object, and it is the SessionCredentials.
 After adding the ajax handlers, the SessionCredentials object is no
 longer
 pickleable.

 (pdb) state=obj.__getstate__()
 (Pdb) cPickle.dumps(state)
 *** UnpickleableError: Cannot pickle type
 'zope.security._proxy._Proxy'
 objects
 (Pdb) state
 'credentials', zope.app.authentication.session.SessionCredentials
 object at 0xafea8fcc),),),)
 (Pdb) credentials=state[0][0][0][1]
 (Pdb) credentials.request_annotations
 {'zope.app.publisher.browser.IUserPreferredLanguages': {'cached':
 ['en-gb', 'en']}, 'z3c.formjs.jsclientevent.caughtEvents':
 [zope.app.publication.interfaces.BeforeTraverseEvent object at
 0xafea8e4c, zope.app.publication.interfaces.BeforeTraverseEvent object
 at 0xafea8dac, zope.app.publication.interfaces.BeforeTraverseEvent
 object at 0xafea8dcc,
 zope.contentprovider.interfaces.BeforeUpdateEvent
 object at 0xafeb1b4c,
 zope.contentprovider.interfaces.BeforeUpdateEvent
 object at 0xafeb1dac,
 zope.contentprovider.interfaces.BeforeUpdateEvent
 object at 0xafeb1d2c,
 

[Zope3-Users] Help: I cannot login after installing z3c.formjs

2008-07-15 Thread kevin gill
Hi,

I am integrating z3c.formjs to a new site. After installing z3c.formjs I
can no longer login. If I remove it, I can login again.

It causes a problem with the SessionCredentials mechanism that I am using.
The SessionCredentials annotations now contains event handlers of type
z3c.formjs.jsclientevent.caughtEvents. These cannot be pickled.

I tried both the PersisentSessionDataContainer and the RamSessionData
Container.

Does anyone have suggestions on how I might proceed with this?

Thanks,

Kevin


This is the tail of the exception

2008-07-15T15:31:38 ERROR SiteError rm.commit(self)
--
2008-07-15T15:31:38 ERROR SiteError   File
/opt/zope3-eggs/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/Connection.py,
line 541, in commit
--
2008-07-15T15:31:38 ERROR SiteError self._commit(transaction)
--
2008-07-15T15:31:38 ERROR SiteError   File
/opt/zope3-eggs/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/Connection.py,
line 586, in _commit
--
2008-07-15T15:31:38 ERROR SiteError
self._store_objects(ObjectWriter(obj), transaction)
--
2008-07-15T15:31:38 ERROR SiteError   File
/opt/zope3-eggs/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/Connection.py,
line 613, in _store_objects
--
2008-07-15T15:31:38 ERROR SiteError p = writer.serialize(obj)  # This
calls __getstate__ of obj
--
2008-07-15T15:31:38 ERROR SiteError   File
/opt/zope3-eggs/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/serialize.py,
line 408, in serialize
--
2008-07-15T15:31:38 ERROR SiteError return self._dump(meta,
obj.__getstate__())
--
2008-07-15T15:31:38 ERROR SiteError   File
/opt/zope3-eggs/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/serialize.py,
line 420, in _dump
--
2008-07-15T15:31:38 ERROR SiteError self._p.dump(state)



I investigated the offending object, and it is the SessionCredentials.
After adding the ajax handlers, the SessionCredentials object is no longer
pickleable.

(pdb) state=obj.__getstate__()
(Pdb) cPickle.dumps(state)
*** UnpickleableError: Cannot pickle type 'zope.security._proxy._Proxy'
objects
(Pdb) state
'credentials', zope.app.authentication.session.SessionCredentials
object at 0xafea8fcc),),),)
(Pdb) credentials=state[0][0][0][1]
(Pdb) credentials.request_annotations
{'zope.app.publisher.browser.IUserPreferredLanguages': {'cached':
['en-gb', 'en']}, 'z3c.formjs.jsclientevent.caughtEvents':
[zope.app.publication.interfaces.BeforeTraverseEvent object at
0xafea8e4c, zope.app.publication.interfaces.BeforeTraverseEvent object
at 0xafea8dac, zope.app.publication.interfaces.BeforeTraverseEvent
object at 0xafea8dcc, zope.contentprovider.interfaces.BeforeUpdateEvent
object at 0xafeb1b4c, zope.contentprovider.interfaces.BeforeUpdateEvent
object at 0xafeb1dac, zope.contentprovider.interfaces.BeforeUpdateEvent
object at 0xafeb1d2c, zope.contentprovider.interfaces.BeforeUpdateEvent
object at 0xafeb1c6c, zope.contentprovider.interfaces.BeforeUpdateEvent
object at 0xafeb1ccc, zope.contentprovider.interfaces.BeforeUpdateEvent
object at 0xafeb1c8c, zope.contentprovider.interfaces.BeforeUpdateEvent
object at 0xafeb1bcc, zope.contentprovider.interfaces.BeforeUpdateEvent
object at 0xafeb322c, zope.contentprovider.interfaces.BeforeUpdateEvent
object at 0xafeb344c, zope.contentprovider.interfaces.BeforeUpdateEvent
object at 0xafeb33cc, zope.contentprovider.interfaces.BeforeUpdateEvent
object at 0xafeb348c, zope.contentprovider.interfaces.BeforeUpdateEvent
object at 0xafeb354c, zope.contentprovider.interfaces.BeforeUpdateEvent
object at 0xafeb35ec, zope.contentprovider.interfaces.BeforeUpdateEvent
object at 0xafeb318c, zope.contentprovider.interfaces.BeforeUpdateEvent
object at 0xafeb362c, zope.contentprovider.interfaces.BeforeUpdateEvent
object at 0xafeb1a4c, zope.contentprovider.interfaces.BeforeUpdateEvent
object at 0xafeb1b6c, zope.contentprovider.interfaces.BeforeUpdateEvent
object at 0xafeb1f8c, zope.contentprovider.interfaces.BeforeUpdateEvent
object at 0xafeb190c, zope.contentprovider.interfaces.BeforeUpdateEvent
object at 0xafeb16ac, zope.contentprovider.interfaces.BeforeUpdateEvent
object at 0xafeb18cc, zope.contentprovider.interfaces.BeforeUpdateEvent
object at 0xafeb172c, zope.contentprovider.interfaces.BeforeUpdateEvent
object at 0xafeb18ac]}
(Pdb)
credentials.request_annotations['z3c.formjs.jsclientevent.caughtEvents'][0]
zope.app.publication.interfaces.BeforeTraverseEvent object at 0xafea8e4c
(Pdb)
cPickle.dumps(credentials.request_annotations['z3c.formjs.jsclientevent.caughtEvents'][0])
*** UnpickleableError: Cannot pickle type 'zope.security._proxy._Proxy'
objects

(Pdb) ev =
credentials.request_annotations['z3c.formjs.jsclientevent.caughtEvents'][0]
(Pdb) ev.object
zope.app.folder.folder.Folder object at 0xb6034b6c
(Pdb) cPickle.dumps(ev.object)
*** UnpickleableError: Cannot pickle type 'zope.security._proxy._Proxy'
objects
(Pdb) cPickle.dumps(ev.request)
*** TypeError: a class that defines __slots__ without defining
__getstate__ cannot 

Re: [Zope3-Users] Help: I cannot login after installing z3c.formjs

2008-07-15 Thread Paul Carduner
Hmm, I've never gotten an error like that.  It probably wouldn't be
too difficult to patch jsclientevent.py by making sure caught events
have security proxies removed before they are stored.  But I wonder
why any request related data is being stored in the database.  My
understanding is that session data gets stored in the database but is
totally separate from the request.  A cookie (stored in the request)
is used to lookup the session data from the database.  My gut instinct
is that there is something wrong with the credentials plugin you are
using because request annotations should never be persisted across
multiple requests.  I am using SessionCredentials myself without any
problems.  Can you find the code path that tries to store the request
annotation?

From a z3c.formjs perspective, if you want the caught events to not be
security proxied, you could create another object event listener (like
the one in z3c/formjs/jsclientevent.py) that goes through the caught
events and removes security proxies.  In the end this is a fragile
solution because you can't guarantee the order in which events are
handled, and unfortunately the way the zcml configuration is split up
(not at all), it would be difficult to override this default event
handler using an exclude directive.

I'm currently making some improvements to z3c.formjs and will make
sure to split up the zcml files more so doing such a customization is
easier.  There should be new releases of z3c.form and z3c.formjs in
the next couple of weeks with these changes.

- Paul

On Tue, Jul 15, 2008 at 7:51 AM, kevin gill [EMAIL PROTECTED] wrote:
 Hi,

 I am integrating z3c.formjs to a new site. After installing z3c.formjs I
 can no longer login. If I remove it, I can login again.

 It causes a problem with the SessionCredentials mechanism that I am using.
 The SessionCredentials annotations now contains event handlers of type
 z3c.formjs.jsclientevent.caughtEvents. These cannot be pickled.

 I tried both the PersisentSessionDataContainer and the RamSessionData
 Container.

 Does anyone have suggestions on how I might proceed with this?

 Thanks,

 Kevin


 This is the tail of the exception

 2008-07-15T15:31:38 ERROR SiteError rm.commit(self)
 --
 2008-07-15T15:31:38 ERROR SiteError   File
 /opt/zope3-eggs/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/Connection.py,
 line 541, in commit
 --
 2008-07-15T15:31:38 ERROR SiteError self._commit(transaction)
 --
 2008-07-15T15:31:38 ERROR SiteError   File
 /opt/zope3-eggs/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/Connection.py,
 line 586, in _commit
 --
 2008-07-15T15:31:38 ERROR SiteError
 self._store_objects(ObjectWriter(obj), transaction)
 --
 2008-07-15T15:31:38 ERROR SiteError   File
 /opt/zope3-eggs/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/Connection.py,
 line 613, in _store_objects
 --
 2008-07-15T15:31:38 ERROR SiteError p = writer.serialize(obj)  # This
 calls __getstate__ of obj
 --
 2008-07-15T15:31:38 ERROR SiteError   File
 /opt/zope3-eggs/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/serialize.py,
 line 408, in serialize
 --
 2008-07-15T15:31:38 ERROR SiteError return self._dump(meta,
 obj.__getstate__())
 --
 2008-07-15T15:31:38 ERROR SiteError   File
 /opt/zope3-eggs/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/serialize.py,
 line 420, in _dump
 --
 2008-07-15T15:31:38 ERROR SiteError self._p.dump(state)



 I investigated the offending object, and it is the SessionCredentials.
 After adding the ajax handlers, the SessionCredentials object is no longer
 pickleable.

 (pdb) state=obj.__getstate__()
 (Pdb) cPickle.dumps(state)
 *** UnpickleableError: Cannot pickle type 'zope.security._proxy._Proxy'
 objects
 (Pdb) state
 'credentials', zope.app.authentication.session.SessionCredentials
 object at 0xafea8fcc),),),)
 (Pdb) credentials=state[0][0][0][1]
 (Pdb) credentials.request_annotations
 {'zope.app.publisher.browser.IUserPreferredLanguages': {'cached':
 ['en-gb', 'en']}, 'z3c.formjs.jsclientevent.caughtEvents':
 [zope.app.publication.interfaces.BeforeTraverseEvent object at
 0xafea8e4c, zope.app.publication.interfaces.BeforeTraverseEvent object
 at 0xafea8dac, zope.app.publication.interfaces.BeforeTraverseEvent
 object at 0xafea8dcc, zope.contentprovider.interfaces.BeforeUpdateEvent
 object at 0xafeb1b4c, zope.contentprovider.interfaces.BeforeUpdateEvent
 object at 0xafeb1dac, zope.contentprovider.interfaces.BeforeUpdateEvent
 object at 0xafeb1d2c, zope.contentprovider.interfaces.BeforeUpdateEvent
 object at 0xafeb1c6c, zope.contentprovider.interfaces.BeforeUpdateEvent
 object at 0xafeb1ccc, zope.contentprovider.interfaces.BeforeUpdateEvent
 object at 0xafeb1c8c, zope.contentprovider.interfaces.BeforeUpdateEvent
 object at 0xafeb1bcc, zope.contentprovider.interfaces.BeforeUpdateEvent
 object at 0xafeb322c, zope.contentprovider.interfaces.BeforeUpdateEvent
 object at 0xafeb344c,