answering myself :)

Jan-Wijbrand Kolman wrote:
> Maybe I miss something very obvious here...
> I created a FooFolder class, subclassing After adding
> the necessary configurations, I have an entry in the addMenu, and I indeed can
> add a FooFolder instance.
> Now I want this FooFolder to become a site right after having added it (so,
> instead of doing this from the ZMI). I naively thought to do this in the
> FooFolder's __init__, like so:
>   from import Folder
>   from import SiteManager
>   class FooFolder(Folder):
>     def __init__(self):
>       super(FooFolder, self).__init__()
>       sitemanager = SiteManager(self)
>       self.setSiteManager(sitemanager)
> This however throws:
>   File "/home/jw/projects/zope3x/lib/python/zope/app/site/", line 
> 81,
> in __init__
>     self._setNext(site)
>   File "/home/jw/projects/zope3x/lib/python/zope/app/site/", line 
> 96,
> in _setNext
>     raise TypeError("Not enough context information")
> Somehow I cannot think of the correct way to do this... Can anyone help? Do I
> need to specify more details?

One way I found, was to register a custom add view class for FooFolders, and
make it override the createAndAdd method, like so:

  from import removeSecurityProxy
  from import SiteManager

  class AddDocumentLibrary(object):

    def createAndAdd(self, data):
      obj = super(AddDocumentLibrary, self).createAndAdd(data)
      bare = removeSecurityProxy(obj)
      sitemanager = SiteManager(bare)

This works, but maybe there're other ways too?


Jan-Wijbrand Kolman
Zope3-users mailing list

Reply via email to