comparison roundup/security.py @ 5269:c94fd717e28c

Fix http://issues.roundup-tracker.org/issue2550952 make __call__ method of a class usable as a check function.
author John Rouillard <rouilj@ieee.org>
date Tue, 19 Sep 2017 22:00:20 -0400
parents 1f72b73d7770
children 35ea9b1efc14
comparison
equal deleted inserted replaced
5268:cc79c0f1651d 5269:c94fd717e28c
45 45
46 limit_perm_to_props_only=False 46 limit_perm_to_props_only=False
47 47
48 def __init__(self, name='', description='', klass=None, 48 def __init__(self, name='', description='', klass=None,
49 properties=None, check=None, props_only=None): 49 properties=None, check=None, props_only=None):
50 import inspect 50 from roundup.anypy import findargspec
51 self.name = name 51 self.name = name
52 self.description = description 52 self.description = description
53 self.klass = klass 53 self.klass = klass
54 self.properties = properties 54 self.properties = properties
55 self._properties_dict = support.TruthDict(properties) 55 self._properties_dict = support.TruthDict(properties)
73 73
74 74
75 if check is None: 75 if check is None:
76 self.check_version = 0 76 self.check_version = 0
77 else: 77 else:
78 args=inspect.getargspec(check) 78 args=findargspec.findargspec(check)
79 # FIXME change args[2] to args.keywords since python 79 # args[2] is the keywords argument. Leave it as a subscript and
80 # 2.6 made getargspec a named tuple once roundup 1.6 released. 80 # do not use named tuple reference as names change in python 3.
81 # If there is a **parameter defined in the function spec, the 81 # If there is a **parameter defined in the function spec, the
82 # value of the 3rd argument in the tuple is not None. 82 # value of the 3rd argument (2nd index) in the tuple is not None.
83 if args[2] is None: 83 if args[2] is None:
84 # function definition is function(db, userid, itemid) 84 # function definition is function(db, userid, itemid)
85 self.check_version = 1 85 self.check_version = 1
86 else: 86 else:
87 # function definition is function(db, userid, itemid, **other) 87 # function definition is function(db, userid, itemid, **other)

Roundup Issue Tracker: http://roundup-tracker.org/