Re: [Zope3-Users] Re: ZCML, practicality, purity (was Excellent perspective...)
Jeff Shell wrote: [snip lots of good stuff about configuration in python code and its drawbacks] But if that were a route one decided to use, one would have to lay down VERY strict rules. Otherwise we lose all the benefits of the Component Architecture and start heading back into a free-for-all mess. I just wanted to indicate, belatedly as I just found this discussion, my strong agreement. If configuration moves into Python code, it should be under very strict supervision indeed. [snip lots more good stuff] . I think that the ZCML situation could be improved with: * simpler use - let Python code say what it adapts and implements. Let Python code subclass from BrowserView. Use ZCML to just register and name the object. Promote this in documentation, advocacy articles, and so on. * alternate syntax? Not Python, but maybe something python-ish but geared towards entering the kind of data references that one has to type a lot in configuration. * cut down on the magics like dynamic class creation. this was a frustrating surprise when I first encountered it a couple of months ago. * for many of the core ZCML configuration directives, explain their Python alternative. Not to promote its use when writing large systems, shared toolkits or frameworks, but to show how to test or just to use adapters and utilities in small applications that don't require the full Zope toolkit. And all of these are a good idea for exploration. Regards, Martijn ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Seeking Zope 3 Equivalent to Zope 2 LocalFS
On Tuesday 17 January 2006 07:05, Jeff Rush wrote: Basically is there any portion of Zope 3 that already has this capability, of providing IFolder but sending file I/O requests into the underlying filesystem? Michael mentions the way to do this for resources. But if you want something more like LocalFS, you have to develop it yourself (and provide it for the community ;-) Regards, Stephan -- Stephan Richter CBU Physics Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Permissions of a given object
Hi, On Sun, Jan 15, 2006 at 11:20:47AM -0500, Stephan Richter wrote: On Thursday 12 January 2006 08:13, Frank Burkhardt wrote: but the problem remains: canAccess returns True for all inaccessible objects. It is hard to guess where your setup is wrong. Does it not work for unit tests, ftests and/or the full application? The full application. In a browser:view I want to query my Catalog to return a list of objects: list = catalog.searchResults(content='findme') list contains a list of objects containing the word 'findme'. Now I want to filter the list to contain only obj, the current principal has access to. permitted_list=[] for obj in list: if canAccess(obj,'__call__'): permitted_list.append(obj) But there's no security proxy wrapping 'obj' s from 'list'. How do I securityproxify 'obj' before being checked by canAccess so that the result of canAccess reflects if the current principal is allowed to access 'obj' ? Maybe I'm completly wrong and there's another way to filter searchresults for objects, the user has access to? Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Permissions of a given object
On Jan 17, 2006, at 10:38 AM, Frank Burkhardt wrote: Hi, On Sun, Jan 15, 2006 at 11:20:47AM -0500, Stephan Richter wrote: On Thursday 12 January 2006 08:13, Frank Burkhardt wrote: but the problem remains: canAccess returns True for all inaccessible objects. It is hard to guess where your setup is wrong. Does it not work for unit tests, ftests and/or the full application? The full application. In a browser:view I want to query my Catalog to return a list of objects: list = catalog.searchResults(content='findme') list contains a list of objects containing the word 'findme'. Now I want to filter the list to contain only obj, the current principal has access to. permitted_list=[] for obj in list: if canAccess(obj,'__call__'): permitted_list.append(obj) But there's no security proxy wrapping 'obj' s from 'list'. How do I securityproxify 'obj' before being checked by canAccess so that the result of canAccess reflects if the current principal is allowed to access 'obj' ? 1) adding a security proxy is done with zope.security.checker.ProxyFactory 2) canWrite and canAccess already do this for you: the code you list should work without modification of the sort that you describe. Maybe I'm completly wrong and there's another way to filter searchresults for objects, the user has access to? The meaning of objects a user can access varies significantly from application to application. You will probably want to optimize this filter by creating an index eventually. For some policies and questions, this might be hard to do well. We'll be releasing an index that does this sort of thing for one kind of use case soon, but it doesn't precisely match what you are doing here. You'll probably want to think about this problem for your app and see how you can index the data. Gary ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Permissions of a given object
Hi, On Tue, Jan 17, 2006 at 10:53:12AM -0500, Gary Poster wrote: [snip] The meaning of objects a user can access varies significantly from application to application. You will probably want to optimize this filter by creating an index eventually. For some policies and questions, this might be hard to do well. We'll be releasing an index that does this sort of thing for one kind of use case soon, but it doesn't precisely match what you are doing here. You'll probably want to think about this problem for your app and see how you can index the data. Even if would write an index for this - I would still need some method to check, if a given principal is allowed to access a given object. Finally, I found a solution: from zope.security.checker import ProxyFactory list=catalog.searchResults(content='findme'); permitted_list=[] for obj in list: defaultview=zapi.getDefaultViewName(obj,self.request) try: view=zapi.queryMultiAdapter((ProxyFactory(obj),self.request),name=viewname) permitted_list.append(view) except Unauthorized: Don't list this one Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Convert from string to class
Hello, I've a string like zope.app.folder.Folder and I want to get the class zope.app.folder.Folder from this string. How can I do that? It's probably more a python problem that Zope... but I hope you excuse. Thanks, Florian ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Convert from string to class
Hi Florian, This function will do the job: def translateDottedName(i): names = i.split('.') module = __import__('.'.join(names[:-1]), {}, {}, ['*']) return getattr(module, names[-1]) Marc Florian Lindner wrote: Hello, I've a string like zope.app.folder.Folder and I want to get the class zope.app.folder.Folder from this string. How can I do that? It's probably more a python problem that Zope... but I hope you excuse. Thanks, Florian ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Convert from string to class
On Jan 17, 2006, at 5:10 PM, Florian Lindner wrote: Hello, I've a string like zope.app.folder.Folder and I want to get the class zope.app.folder.Folder from this string. How can I do that? It's probably more a python problem that Zope... but I hope you excuse. Was just rewriting this for myself, as a matter of fact--something I need now and then. This is today's spelling: def getImport(s): ... try: ... return __import__(s, globals(), {}, ['ignored']) ... except ImportError: ... elements = s.split('.') ... last = elements.pop() ... mod = '.'.join(elements) ... mod_obj = __import__(mod, globals(), {}, [last]) ... return getattr(mod_obj, last) ... getImport('xml.sax.saxutils.unescape') function unescape at 0x28b630 getImport('xml.sax.saxutils') module 'xml.sax.saxutils' from '/Library/Frameworks/Python.framework/ Versions/2.4/lib/python2.4/xml/sax/saxutils.pyc' Could be refined a bit, but that's the idea. Gary ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Convert from string to class
Hello, what about: http://www.talkaboutprogramming.com/group/comp.lang.python/messages/318370.html Markus 17.01.2006 23:10, Florian Lindner: Hello, I've a string like zope.app.folder.Folder and I want to get the class zope.app.folder.Folder from this string. How can I do that? It's probably more a python problem that Zope... but I hope you excuse. Thanks, Florian ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] CalCore from CPS and Zope3?
Hi! I am intrested in making CalCore to work Zope3, however, I have not found anything that says CalCore can work inside Zope3 fo rnow. Are there any plans on this if anybody knows? Is it easy to DIY? Thanks! Sincerely yours, Roman Suzi ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Re: Seeking Zope 3 Equivalent to Zope 2 LocalFS
Michael Haubenwallner wrote: Jeff Rush wrote: The Resource directive exposes a single file, say a .CSS or favicon.png, but I'm not seeing that it can expose an entire directory tree. The browser:resourceDirectory works for me, here is eg. the 'configure.zcml' of a package that just holds files and folders:: Ah, yes I'd forgotten there was a resourceDirectory as well as a resource directive. I kept looking for a resource package but it's in the publisher package. Thanks, although I think I'm going to have to implement LocalFS to get all the flexibility I need. -Jeff ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users