logo       

Re: Re: How do deal with cmfcatalog-wrapped objects?: msg#00041

web.zope.z3base.five

Subject: Re: Re: How do deal with cmfcatalog-wrapped objects?

Both solution appear a bit "heavy" to me. I solved this issue for TextIndexNG3 by adding generic support for wrapped objects by introducing an
IObjectWrapper interface which is checked by the indexer. Using five:implements it is easy to attach this interface - if necessary - to any
wrapper class (including IndexableObjectWrapper@CMFCore). Writing an adapter
for adapting IndexableObjectWrapper to IObjectWrapper is trivial. I think this solution is more straight forward and does not require any changes
to the CMF.

-aj

--On 31. März 2006 14:11:58 +0200 Philipp von Weitershausen <philipp-EUFZ76H3/usuiJZBYc8SzA@xxxxxxxxxxxxxxxx> wrote:

1. I think for the long term, IndexableObjectWrapper could be made a
decorator. This works as follows:

from zope.proxy import getProxiedObject
from zope.app.decorator import Decorator

class IndexableObjectWrapper(Decorator):

def allowedRolesAndUsers(self):
ob = getProxiedObject(self)
allowed = {}
for r in rolesForPermissionOn(View, ob):
allowed[r] = 1
localroles = _mergedLocalRoles(ob)
for user, roles in localroles.items():
for role in roles:
if allowed.has_key(role):
allowed['user:' + user] = 1
if allowed.has_key('Owner'):
del allowed['Owner']
return list(allowed.keys())

2. In the short term we can apply the following trick
(IndexableObjectWrapper needs to be a new style class!):

from zope.interface import providedBy
from zope.interface.declarations import ObjectSpecificationDescriptor
from zope.interface.declarations import getObjectSpecification
from zope.interface.declarations import ObjectSpecification

class IndexableObjectSpecification(ObjectSpecificationDescriptor):

def __get__(self, inst, cls=None):
if inst is None:
return getObjectSpecification(cls)
else:
provided = providedBy(inst.__ob)
cls = type(inst)
return ObjectSpecification(provided, cls)

class IndexableObjectWrapper(object): # new-style!
implements(...) # it can implement as much as it wants
__providedBy__ = IndexableObjectSpecification()

...

Attachment: pgplIGqiKj931.pgp
Description: PGP signature

_______________________________________________
Zope-CMF maillist - Zope-CMF-lEa0QfImRKZ5o+NzvwT5Tw@xxxxxxxxxxxxxxxx
http://mail.zope.org/mailman/listinfo/zope-cmf

See http://collector.zope.org/CMF for bug reports and feature requests
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise