[Grok-dev] zope.app.keyreference.interfaces.NotYet(object)
Sebastian Ware
sebastian at urbantalk.se
Sun Jul 15 05:49:39 EDT 2007
What surprised me was that that kind of assignment worked with my
grok.Application object...
class ProtonCMS(grok.Application, grok.Container):
interface.implements(interfaces.IProtonCMS)
def __init__(self):
super(ProtonCMS, self).__init__()
self.title = ''
self.description = ''
self['default'] = protonworkflow.ProtonWorkflow()
...and I was expecting the "class ProtonContainer(grok.Container,
protonobject.ProtonObject)" to work in the same way.
Do you know why I can make the assignment in the grok.Application
object but not in the grok.Container object?
Mvh Sebastian
15 jul 2007 kl. 03.06 skrev Darryl Cousins:
> Hi Sebastian,
>
> On Sun, 2007-07-15 at 02:40 +0200, Sebastian Ware wrote:
>> Hi!
>>
>> I am getting a zope.app.keyreference.interfaces.NotYet(object)
>> exception when creating an instance of a class with the following
>> __init__. I can find any documentation on the exception, does anyone
>> know what might be the cause of the error?
>>
>> class ProtonContainer(grok.Container, protonobject.ProtonObject):
>>
>> def __init__(self, creator_id, object_type, title, body,
>> authors):
>> super(ProtonContainer, self).__init__()
>>
>> self.object_type = object_type
>> self.tabs = [{'id':'', 'name':'', 'allowed_object_types':
>> ['type_1', 'type_2']}]
>>
>> self['files'] = 'how are you?'
>
> Here you are adding to the container before it is fully initiated. I
> forget the details as to where this raises NotYet error (I think it
> happens with ObjectAddedEvent IIRC).
>
> You can get around this by using a subscriber (one of probably many
> solutions):
>
> @grok.subscribe(ProtonContainer, grok.IObjectAddedEvent)
> def assign_files(obj, evt):
> obj['files'] = 'how are you?'
>
> Or perhaps you simply meant to use self.files? Usually containers
> contain objects.
>
> Regards,
> Darryl
>
>
>> self.title = title
>> self._creator_id = creator_id
>> self._creation_timestamp = datetime.datetime.now()
>> self.body = body
>> self.authors = authors
>>
>> *** TRACEBACK ***
>>
>> File "/Users/jhsware/GrokProjects/ProtonCMS/src/protoncms/
>> protoncontainer.py", line 92, in add
>> new_obj = ProtonContainer(creator_id =
>> self.request.principal.id, object_type='article', **data)
>> File "/Users/jhsware/GrokProjects/ProtonCMS/src/protoncms/
>> protoncontainer.py", line 22, in __init__
>> self['files'] = 'how are you?'
>> File "/local/zope3.3/lib/python/zope/app/container/sample.py",
>> line 86, in __setitem__
>> setitem(self, self.__data.__setitem__, key, object)
>> File "/local/zope3.3/lib/python/zope/app/container/contained.py",
>> line 593, in setitem
>> notify(event)
>> File "/local/zope3.3/lib/python/zope/event/__init__.py", line 23,
>> in notify
>> subscriber(event)
>> File "/local/zope3.3/lib/python/zope/component/event.py", line 26,
>> in dispatch
>> for ignored in zope.component.subscribers(event, None):
>> File "/local/zope3.3/lib/python/zope/component/_api.py", line 130,
>> in subscribers
>> return sitemanager.subscribers(objects, interface)
>> File "/local/zope3.3/lib/python/zope/component/registry.py", line
>> 290, in subscribers
>> return self.adapters.subscribers(objects, provided)
>> File "/Users/jhsware/GrokProjects/ProtonCMS/eggs/tmpbrEvl3/
>> zope.interface-3.4.0b1-py2.4-macosx-10.3-i386.egg/zope/interface/
>> adapter.py", line 535, in subscribers
>> File "/local/zope3.3/lib/python/zope/component/event.py", line 33,
>> in objectEventNotify
>> adapters = zope.component.subscribers((event.object, event),
>> None)
>> File "/local/zope3.3/lib/python/zope/component/_api.py", line 130,
>> in subscribers
>> return sitemanager.subscribers(objects, interface)
>> File "/local/zope3.3/lib/python/zope/component/registry.py", line
>> 290, in subscribers
>> return self.adapters.subscribers(objects, provided)
>> File "/Users/jhsware/GrokProjects/ProtonCMS/eggs/tmpbrEvl3/
>> zope.interface-3.4.0b1-py2.4-macosx-10.3-i386.egg/zope/interface/
>> adapter.py", line 535, in subscribers
>> File "/local/zope3.3/lib/python/zope/app/intid/__init__.py", line
>> 163, in addIntIdSubscriber
>> key = IKeyReference(ob, None)
>> File "/local/zope3.3/lib/python/zope/app/component/hooks.py", line
>> 96, in adapter_hook
>> return siteinfo.adapter_hook(interface, object, name, default)
>> File "/local/zope3.3/lib/python/zope/security/adapter.py", line
>> 88, in __call__
>> adapter = self.factory(*args)
>> File "/local/zope3.3/lib/python/zope/app/keyreference/
>> persistent.py", line 41, in __init__
>> raise zope.app.keyreference.interfaces.NotYet(object)
>> NotYet: how are you?
>>
>>
>> Mvh Sebastian
>>
>>
>> _______________________________________________
>> Grok-dev mailing list
>> Grok-dev at zope.org
>> http://mail.zope.org/mailman/listinfo/grok-dev
>
More information about the Grok-dev
mailing list