[Zope3-Users] There isn't enough context to get URL information.

Achim Domma domma at procoders.net
Thu May 25 05:50:40 EDT 2006


Hi,

I try to figure out how to make attributes holding content objects 
accessible via the browser. Using the code below, I get a "There isn't 
enough context to get URL information." exception if I try to access the 
attribute via URL or via Introspector.

The exception is raised in the breadcrumbs function in absoluteurl.py. 
It looks like the __parent__ attribute of the contained object is not 
set, but I don't understand why?

This is the interface of the object holding subobjects:

class IWorkspace(ISimpleReadContainer):
     title = TextLine(
        title=u"Title",
        description=u"The title",
        default=u"proCoders Workspace",
        required=True)
     projects = Container(title=u"Projects", description=u"xxx")
     articles = Container(title=u"Articles", description=u"xxx")


The object is implemented as:

class Workspace(Persistent):
     implements(IWorkspace)
     title=u'proCoders workspace'
     projects=None
     articles=None

     def __getitem__(self,key):
         return getattr(self,key)

     def get(self,key, default=None):
         return getattr(self,key)

To initialize projects and articles, I have registered an event 
subscriber:

def onObjectCreated(parent,event):
     if IWorkspace.providedBy(event.object):
         workspace=IWorkspace(event.object)
         setitem(workspace,
           workspace.__setattr__,"projects",ProjectFolder())
         setitem(workspace,
           workspace.__setattr__,"articles",ArticleFolder())

regards,
Achim


More information about the Zope3-users mailing list