Re: [Zope3-Users] Principal annotations

2006-03-11 Thread Gary Poster


On Mar 11, 2006, at 3:14 AM, Thierry FLORAC wrote:


On Thu, 2006-03-09 at 01:14 -0700, Shane Hathaway wrote:
Your idea of annotating InternalPrincipals rather than Principals  
seems

to work, but I apparently did something wrong, because edited
annotations don't persist!  I can save edits, but when I reload the
page, they're gone.  I don't know why.


As said in a previous (and un-replied :-( !) post a few days ago, I  
have
the same kind of problem with an adapter using annotations : if I  
set my

attributes using a property attribute, the setter is not called and
modifications are lost when page is reloaded ; I have to call the  
setter
directly (after modifying the interface, of course) from my adapter  
for

modifications to be stored...


I haven't had time to read much or reply, so these may not be what  
you and Shane are talking about, but I just saw this...


- yes, don't annotate principals.  principal objects are not  
persistent, and like the Zope 2 PAS are created and discarded within  
a request.  annotating internal principals is not recommended either:  
it won't work with other plugin designs.  Use principal annotations.   
Make sure that the adapter providing IAnnotations for principals  
returns the principal annotations.  (I thought I had done this for  
Zope 3, but maybe I just did it for some internal work...)


- Thierry, send me a link to your email and I'll try to look at it  
(especially if it is short :-) ).  It could be that you are not using  
a persistent-aware data structure (PersistentDict or a BTree).  We  
successfully do the sort of thing you seem to be describing, so I  
suspect some disconnect.


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


[Zope3-Users] Can't make site of a BTreeContainer

2006-03-11 Thread 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.

Thanks for any help,

  Thierry



-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

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