hi all

i am using tg 1.0.8.

want to add a custom identity predicate, say i want to call it
is_admin_of.

i define it in identity.py in the project directory following
directions from 
http://docs.turbogears.org/1.0/IdentityRecipes?action=show&redirect=1.0%2FIdentityRecipies#id2:


class is_admin_of(Predicate, IdentityPredicateHelper):
    error_message = u"Not an admin of the group."

    def __init__(self,code):
        self.obj = Kvutza.get_by(code=code)

    def eval_with_object(self, identity, errors=None):

        if identity.admins(self.obj):
            return True
        else:
            self.append_error_message(errors)
            return False

next i import my new identity file from the project's root controller
root.py:
...
from noaltg.utils import PhotoBox, RemoteLink, before_time
from noaltg.identity import *
from turbogears.widgets import LinkRemoteFunction
..

next i decorate one of my controller methods to check it:

    @identity.require(identity.is_admin_of("9"))
    @expose(template='genshi:noaltg.templates.kvutzot.form')
    def edit(self, id, **kw):
...

my code breaks.

AttributeError: 'module' object has no attribute 'is_admin_of'

what am i doing wrong?

thanks in advance,

Rotem Tamir



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to