Hi all,
I need to make a class implements a new interface at run time.
The use case:
I want that the user select what Content Type will be rateable, via site setup.
This works ok with contentratings and plone.contentratings, but I need index the rates of selected types.
I added a subscriber to IObjectRatedEvent:
<subscriber for="*
contentratings.interfaces.IObjectRatedEvent" handler=".subscribers.reindexRating"
/>And did:
def reindexRating(obj, event):
try: rated = IUserRating(obj)
except (ComponentLookupError, TypeError, ValueError): # The catalog expects AttributeErrors when a value can't be found
return obj.averageRating = rated.averageRating
obj.numberOfRatings = rated.numberOfRatings obj.reindexObject(idxs=['averageRating', 'numberOfRatings'])
# another approach, I don't know what is correct, yet. :-/ #rated.reindexObject(idxs=['averageRating', 'numberOfRatings'])
But, all objects can't be adapted to IUserRating interface, so I want to do something like below, after user configure the Type in Ratings configlet in Site Setup.
classImplements(obj.__class__, IUserRating) # I know that is wrong :-)
How can I do that classImplements or how can I get the class of a Content Type ?
Thanks a lot,
--
Luciano Pacheco
Simples Consultoria
www.simplesconsultoria.com.br
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.
http://p.sf.net/sfu/bobj-july_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users