Am Samstag, 11. März 2006 16:59 schrieb Thierry FLORAC:
>   Hi,
>
> I'm currently building a photo management application for which I need
> to setup local utilities (a catalog...), so I want to make a site of my
> main folder, which is called a gallery.
> My current problem is that I can't define the folder as a site manager
> if it is subclassed from BTreeContainer ; the same code that follows
> works perfectly if my Gallery class just inherits from Folder.
> Here is the main structure of my code, mainly extracted from the "cubic"
> portal :
>
>         class IGalleryContainer (IContainer):
>             """Marker interface"""
>
>         class IGalleryFolder (IGalleryContainer):
>             """Photo management folder"""
>             def __setitem__ (name, object):
>                 """Add a new sub-folder"""
>             __setitem__.precondition =
> ItemTypePrecondition(IGalleryContainer,IGalleryPhoto)
>
>         class IGallery (IGalleryFolder):
>             """Marker interface"""
>
>         class GalleryFolder (BTreeContainer):
>             """Photo management folder"""
>
>             implements (IGalleryFolder)
>
>         class Gallery (GalleryFolder, SiteManagerContainer):
>             """Main gallery site"""
>
>             implements (IGallery)
>
>             def setupSiteManager(self):
>                 """Setup a sitemanager and related utilities
>
>                 Invoked through the setupGallery handler
>                 """
>                 self.setSiteManager(LocalSiteManager(self))
>                 setSite(self)
>
>                 default = self.getSiteManager()['default']
>                 reg_manager = default.registrationManager
>
>                 if 'intid' not in default:
>                     intids = IntIds()
>                     default['intid'] = intids
>                     intids_reg = UtilityRegistration('', IIntIds, intids)
>                     reg_manager.addRegistration(intids_reg)
>                     intids_reg.status = ActiveStatus
>
>                 if 'catalog' not in default:
>                     catalog = Catalog()
>                     default['catalog'] = catalog
>                     catalog_reg = UtilityRegistration('catalog', ICatalog,
> catalog) reg_manager.addRegistration(catalog_reg)
>                     catalog_reg.status = ActiveStatus
>
>                 catalog = default['catalog']
>                 index = SetIndex(field_name='getPathElements',
> interface=IPathElements, field_callable=True) catalog['path'] = index
>                 ...
>
> In fact, at the end of the "setupSiteManager" method, which is called
> through an event subscriber, "zapi.getPath(default)" returns the correct
> path (/mygallery/++etc++site/default) and the gallery folder is
> correctly marked as being a site in introspector. No exception is raised
> while setting the site, but any try to follow the "Site management" link
> returns an error, and the ++etc++site "sub-folder" seems to be
> vanished !
> The same problem appears if I don't call the "setupSiteManager" and try
> to create the site through the "Make a site" link.


Hi,

try to also derive your interface of the object that should become a site from 
zope.app.component.interfaces.IPossibleSite

 class IGallery (IGalleryFolder, IPossibleSite):


Hope this helps,

Florian
_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to