logo       

Re: Re: [Zope-CMF] Re: How do deal with cmfcatalog-wrapped objects?: msg#00051

web.zope.z3base.five

Subject: Re: Re: [Zope-CMF] Re: How do deal with cmfcatalog-wrapped objects?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Just worked in the same area. I actually realised for our code, that we need two adapter, which reraises the question, how to reach for the real object for this adapters.

Two adapters:

Something like allowedRolesAndUsers is IMO a policy of the catalog or the overall system. Additionally there needs to be an adapter/ Interface to provide an object with the methods necessary for the selection of indices. This is more a descision of the developer of the object, or a particular application.

I think it is not a good solution, that the object-specific adapter inherits from the catalog-specific adapter.

So one ends up with a double wrapped object, where the outer catalog- specific adapter needs to have access to the real object. How is this handled best? Is there a generic unwrap()-method?

__Janko


Am 07.04.2006 um 07:38 schrieb Andreas Jung:

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@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()

...

_______________________________________________
z3-five mailing list
z3-five@xxxxxxxxxxxxx
http://codespeak.net/mailman/listinfo/z3-five

- --
Janko Hauser email: jhauser@xxxxxxxxx
mobile: +49 1721 641552


-----BEGIN PGP SIGNATURE-----

iD8DBQFEOSV9e7bTUi4B2KARAoY2AJ9NG3tEJsnIjpjYZ/TNGMBck1DvTgCglyPI
nTv9mO4vUhMRCXH0RldT2dY=
=YFv7
-----END PGP SIGNATURE-----


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise