Commits

Anonymous committed 79127a3

update - access args and kwargs of decorated methods

Comments (0)

Files changed (2)

reactorauth/__init__.py

     
     def validate(func, self, *args, **kwargs):
         try:
-            valid.check()
+            print args, kwargs
+            valid.check(org_args=args, org_kwargs=kwargs)
         except NotValidAuth, e:
             return handler(e)
         return func(self, *args, **kwargs)
 
 class BaseCondition(object):
     """ This is base class :P maybe it will handle translations in future, for now one could extend one of parsers to hook in gettext"""
-    pass
+    def __init__(self, *args, **kwargs):
+        raise NotImplementedError('Not implemented yet')
+    
+    def check(self, org_args=None, org_kwargs=None):
+        raise NotImplementedError('Not implemented yet')
 
 class AllMet(BaseCondition):
     """ Condition class that required every check to successfully evaluate.
         self.conditions = args
         self.message = kwargs.get('message', u'All of these conditions have to be met:')
     
-    def check(self):
+    def check(self, org_args=None, org_kwargs=None):
         sub_conditions = []
         valid = True
         for condition in self.conditions:
             try:
-                condition.check()
+                condition.check(org_args, org_kwargs)
             except NotValidAuth, e:
                 valid = False
                 sub_conditions.append(e)
         self.conditions = args
         self.message = kwargs.get('message', u'At least one of these conditions have to be met:')
     
-    def check(self):
+    def check(self, org_args=None, org_kwargs=None):
         sub_conditions = []
         valid = False
         for condition in self.conditions:
             try:
-                condition.check()
+                condition.check(org_args, org_kwargs)
                 return True
             except NotValidAuth, e:
                 sub_conditions.append(e)
         self.conditions = args
         self.message = kwargs.get('message', u'All of these conditions have to be not met:')
     
-    def check(self):
+    def check(self, org_args=None, org_kwargs=None):
         sub_conditions = []
         valid = True
         for condition in self.conditions:
             try:
-                condition.check()
+                condition.check(org_args, org_kwargs)
                 valid = False
             except NotValidAuth, e:
                 sub_conditions.append(e)

reactorauth/pylonslib/__init__.py

         self.permissions = args
         self.message = kwargs.get('message', u'User must have permission:')
     
-    def check(self):
+    def check(self, org_args=None, org_kwargs=None):
         from pylons import request
         if 'REMOTE_USER' in request.environ:
             for permission in request.user.permissions:
         self.permissions = args
         self.message = kwargs.get('message', u'User must have permissions:')
     
-    def check(self):
+    def check(self, org_args=None, org_kwargs=None):
         from pylons import request
         if 'REMOTE_USER' in request.environ:
             met_permissions = 0
         self.groups = args
         self.message = kwargs.get('message', u'User must belong to groups:')
     
-    def check(self):
+    def check(self, org_args=None, org_kwargs=None):
         from pylons import request
         if 'REMOTE_USER' in request.environ:
             met_groups = 0
         self.groups = args
         self.message = kwargs.get('message', u'User must belong to at least one of groups:')
     
-    def check(self):
+    def check(self, org_args=None, org_kwargs=None):
         from pylons import request
         if 'REMOTE_USER' in request.environ:
             for group in request.user.groups:
     def __init__(self, message=u'User needs to be logged in'):
         self.message = message
     
-    def check(self):
+    def check(self, org_args=None, org_kwargs=None):
         from pylons import request
         if 'REMOTE_USER' in request.environ:
             return True