[Zope3-Users] Re: Function that is called when object is fully
instantiated
Florian Lindner
mailinglists at xgm.de
Tue Nov 21 16:38:38 EST 2006
Am Dienstag, 21. November 2006 04:08 schrieb Fred Drake:
> On 11/20/06, Florian Lindner <mailinglists at xgm.de> wrote:
> > I use is this way:
> >
> > def onObjectAdded(event):
> > if IJabberClient.providedBy(event.object):
> > event.object.finishInitialization()
> >
> > the function is outside the class and is registered as a subscriber for
> > IObjectAddedEvent
>
> This could be made a handler for [IJabberClient, IObjectAddedEvent],
> and skip the providedBy() test in the handler.
>
> > but inside finishInitialization there are still no values from the schema
> > set to the values I entered on the web-form. There are still at the
> > default values I set them like that: (var1 and var2)
>
> Are you using browser:addform? There are four different attributes
> that can be used to tailor when attributes of the object are set:
> arguments, keyword_arguments, set_before_add, and set_after_add.
> Fields that are input but not included in any of these are set after
> adding the object to it's container.
Ok, I've added set_before_add="some of my schema fields" to the addform
directive and it works. But now I get:
2006-11-21T22:36:16 ERROR SiteError
http://horus.local:8080/++etc++site/default/+/AddJabberClient.html%3D
Traceback (most recent call last):
File "/home/florian/Zope3/src/zope/publisher/publish.py", line 138, in
publish
publication.afterCall(request, obj)
File "/home/florian/Zope3/src/zope/app/publication/browser.py", line 78, in
afterCall
super(BrowserPublication, self).afterCall(request, ob)
File "/home/florian/Zope3/src/zope/app/publication/zopepublication.py", line
167, in afterCall
txn.commit()
File "/home/florian/Zope3/src/transaction/_transaction.py", line 395, in
commit
self._commitResources()
File "/home/florian/Zope3/src/transaction/_transaction.py", line 495, in
_commitResources
rm.commit(self)
File "/home/florian/Zope3/src/ZODB/Connection.py", line 498, in commit
self._commit(transaction)
File "/home/florian/Zope3/src/ZODB/Connection.py", line 543, in _commit
self._store_objects(ObjectWriter(obj), transaction)
File "/home/florian/Zope3/src/ZODB/Connection.py", line 570, in
_store_objects
p = writer.serialize(obj) # This calls __getstate__ of obj
File "/home/florian/Zope3/src/ZODB/serialize.py", line 407, in serialize
return self._dump(meta, obj.__getstate__())
File "/home/florian/Zope3/src/ZODB/serialize.py", line 416, in _dump
self._p.dump(state)
TypeError: expected string or Unicode object, NoneType found
after my IObjectAddedEvent has been called and the called function had
returned.
Do you know what's wrong here?
Thanks,
Florian
More information about the Zope3-users
mailing list