[Zope3-Users] Users and the Ownership of Objects
Dear list, I have a number of questions. I've split them up over a number of emails, to keep them 'bite sized', and hopefully make any replies more useful in the archive. Apologies if this is not considered correct 'etiquette' on this list. Is there any recommended method for indicating ownership of objects by a user? There is potentially a 'many-many' mapping of objects to users, so I don't want to use containment to indicate this relationship. Would it be sensible to use Annotations to store a list of principals that are associated with the object on the object? I need to be able to call up the objects related to a user, and I'm intending to use a Catalog to call the list of objects up. Is this compatible with an annotations-based approach - i.e., would I face any difficulties getting the Catalog to read data from annotations? Also, we will need to combine this with our security system - each user will be able to edit objects that they are registered as the owner of (probably with workflow constraints...). Is this possible within the default zope security policy, or will I have to write a new one (which is a daunting prospect!) There will also be system administrators who will have the rights to edit any of the objects, so the concept of roles will work well for them, but I've not been able to see how/if I would be able to grant a principal permission to edit only those objects that she is registered as an 'owner' of using the standard zcml declarations (which, as I understand it, grant permission on, say, a whole class of objects). Thanks, James ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] User data / metadata
Hello list, A small 'conceptual' question... Both Stephan and Philipp's books recommend using principal metadata to store users' email addresses etc. If I intend to use the email addresses (and other contact information I want to store for the user) within the application (i.e., other objects will want to present it on screen), has it crossed the border from metadata to data, and would it consequently make sense to define principals with these attributes directly? Thanks, James ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Problems with a catalog
On Sep 27, 2005, at 10:01 PM, Tom Dossis wrote: 1. How do I add a catalog to a site ? Hi Tom. Looks like you might have already worked yourself out of this, but I'll respond for the list, at least. If you are creating and configuring a site programmatically within a single transaction, and adding multiple tools, some of which depend on the others, then you typically need to do a setSite dance around the whole thing. For instance (and there are many variations, such as creating a site then letting event subscribers respond, but here's a simple case): 8 import zope.app.component.hooks # I believe this location is slated for improvement import zope.event import zope.app.event.objectevent def makesite(container, name): object = MySiteFactory() zope.event.notify(zope.app.event.objectevent.ObjectCreatedEvent (object)) container[name] = object sm = zope.app.component.site.LocalSiteManager(object) zope.event.notify(zope.app.event.objectevent.ObjectCreatedEvent (sm)) object.setSiteManager(sm) old_site = zope.app.component.hooks.getSite() zope.app.component.hooks.setSite(object) try: # XXX build your tools in the site manager here, and do other configuration finally: zope.app.component.hooks.setSite(old_site) 8 Moreover, you may also need direction in adding local utilities. The general pattern is this. This also may be slated for improvement, like the location for the getSite/setSite import above. Given an object that is a site (i.e., has a site manager): - get the site manager (sm = site.getSiteManager()) - get the package into which you want to add the utility (pkg = sm ['default']) - create the utility - fire off a creation event, as illustrated in code above - get a name chooser for the package and ask it to choose a name for the utility (name_in_package = zope.app.container.interfaces.INameChooser(package).chooseName (suggested_name, utility)) - add it to the package (pkg[name_in_container] = utility) - make a utility registration for name and interface you are going to look up the utility with--note this is usually *not* the name_in_package above (reg = zope.app.utility.UtilityRegistration (name, interface, utility)) - add the registration to the package's registration manager (pkg.registrationManager.addRegistration(reg)) - make the registration active (reg.status = zope.app.component.interfaces.registration.ActiveStatus) Whew! Hope that helps Gary ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Adding indexes to a Catalog tool subclass
On Sep 28, 2005, at 1:53 AM, Tom Dossis wrote: I can add a tool which is a simple subclass of Catalog. However if I try to add some index(es) in the constructor it fails with a NotYet error (see below). Is there a simple way to achieve this? Yes. Don't add the indexes with the constructor. Add the catalog as a full utility first, as I described in my previous email, then start adding indexes. Gary ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Users and the Ownership of Objects
On Sep 28, 2005, at 9:16 AM, Jim Fulton wrote: Note that in the Sharing policy that we'll be releasing (soon, I hope), the sharing privilege is pretty darn close to ownership, as we've discussed. Oh, yeah. :-) Cool. Gary ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] History of an Object
On 9/28/05, Gary Poster [EMAIL PROTECTED] wrote: A Zope object versioning system is more appropriate for this case. One take is in the zope trunk now--maybe zope.app.versioning? zope.app.versioncontrol -Fred -- Fred L. Drake, Jr.fdrake at gmail.com Zope Corporation ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Users and the Ownership of Objects
Thanks for the quick responses. Is there anywhere I can read up on what the Sharing policy mentioned will be like? Thanks, James On 28/09/05, Gary Poster [EMAIL PROTECTED] wrote: On Sep 28, 2005, at 9:16 AM, Jim Fulton wrote: Note that in the Sharing policy that we'll be releasing (soon, I hope), the sharing privilege is pretty darn close to ownership, as we've discussed. Oh, yeah. :-) Cool. Gary ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] User data / metadata
On 9/28/05, James Allwyn [EMAIL PROTECTED] wrote: Hello list, A small 'conceptual' question... Both Stephan and Philipp's books recommend using principal metadata to store users' email addresses etc. If I intend to use the email addresses (and other contact information I want to store for the user) within the application (i.e., other objects will want to present it on screen), has it crossed the border from metadata to data, and would it consequently make sense to define principals with these attributes directly? You could do it directly. In fact, you could even have 'members' as regular content objects in the site and write an authentication utility which looks up those members and builds a security Principal object off of that. I believe this is what Schoolbell does. http://schooltool.org/ ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] images in a content object
On Sep 27, 2005, at 12:21 PM, Duncan McGreggor wrote: On Sep 27, 2005, at 12:09 PM, Jean-Marc Orliaguet wrote: http://svn.nuxeo.org/trac/pub/file/z3lab/cpsskins/branches/jmo- perspectives/browser/caching.py On Sep 27, 2005, at 12:13 PM, Benji York wrote: Chapter 35 of Stephan's book. I couldn't find traverse in the index of Philipp's book, but I'm sure he covers it somewhere. Also note that it might be better to create a content space image object instead and just keep a reference to it in your other content object, then you *could* use absolute URL. You guys are awesome -- these were just the tips I needed to get past this block -- thanks for your help! In addition to these fine suggestions, I'll add another. From Stephan Richter's code in the schoolbell repository: http://tinyurl.com/83bg8 There is a person content object that has a photo attached. To use it, I only needed to: 1) add some browser view code, and 2) add the zcml configuration for it. The original part of my schema that I had posted was this: class IPage(Interface): ... ... image_file = Bytes( title=uImage, description=uUpload an associated image here, required=False) Then I added this browser view code: from zope.app.file.image import Image class ImageView(BrowserView): View that returns a page image. __used_for__ = IPage def __call__(self): data = self.context.image_file image = Image(data) if not image: raise NotFound(self.context, u'image_file', self.request) self.request.response.setHeader('Content-Type', image.contentType) return data The final step was the zcml: browser:page name=image_file for=.interfaces.IPage class=.browser.ImageView permission=zope.View / I was then able to create an instance of my content object (a Page, implementing IPage), and access the attached image via the url http://localhost/mypage.html/image_file Thanks again for all the help, and I hope this is useful for others :-) d ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Adding indexes to a Catalog tool subclass
Gary Poster wrote: On Sep 28, 2005, at 1:53 AM, Tom Dossis wrote: I can add a tool which is a simple subclass of Catalog. However if I try to add some index(es) in the constructor it fails with a NotYet error (see below). Is there a simple way to achieve this? Yes. Don't add the indexes with the constructor. Add the catalog as a full utility first, as I described in my previous email, then start adding indexes. An interesting observation .. 1. Adding content into a container in the constructor does work... 2. Adding a Unique Id Utility will stop it working (NotYet error). e.g. class Contained(Persistent): implements(IContained) class Container(BTreeContainer): implements(IContainer) def __init__(self): super(Container, self).__init__() self[u'small'] = Contained() self[u'medium'] = Contained() self[u'large'] = Contained() Should this pattern be considered taboo in z3? ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users