X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=PLC%2FAccessors%2FFactory.py;h=ebe67204ed57287cb3c69a3fcab82ba94c68cc12;hb=f7ddb15c75cc235ee0592ac4f03005f8ce62a7d1;hp=fc1cb1741a7d51b2824e63c5d12202ca8bbd1be1;hpb=4a6fe0318507843ee20513ff26b20fc4962c4ed0;p=plcapi.git diff --git a/PLC/Accessors/Factory.py b/PLC/Accessors/Factory.py index fc1cb17..ebe6720 100644 --- a/PLC/Accessors/Factory.py +++ b/PLC/Accessors/Factory.py @@ -1,7 +1,6 @@ +# # Thierry Parmentelat - INRIA -# $Id$ -# $URL$ - +# from types import NoneType from PLC.Faults import * @@ -25,9 +24,7 @@ from PLC.PersonTags import PersonTags, PersonTag # this is another story.. #from PLC.Ilinks import Ilink -from PLC.TagTypes import TagTypes, TagType - -# known classes : { class -> secondary_key } +# known classes : { class -> details } taggable_classes = { Node : {'table_class' : Nodes, 'joins_class' : NodeTags, 'join_class' : NodeTag, 'secondary_key': 'hostname'}, @@ -60,17 +57,22 @@ tech_roles = [ 'admin', 'pi', 'tech' ] # The expose_in_api flag tells whether this tag may be handled # through the Add/Get/Update methods as a native field # -# note: tag_min_role_id gets attached to the tagtype instance, +# note: roles get attached to the tagtype instance, # while get_roles and set_roles get attached to the created methods # this might need a cleanup # # in addition a convenience method like e.g. LocateNodeArch is defined # in the Accessor class; its purpose is to retrieve the tag, or to create it if needed +# +# Legacy NOTE: +# prior to plcapi-5.0-19, this used to accept an additional argument +# named min_role_id; this was redundant and confusing, it has been +# removed, we now use set_roles to restrict access on the corresponding tag def define_accessors (module, objclass, methodsuffix, tagname, category, description, - get_roles=['admin'], set_roles=['admin'], - tag_min_role_id=10, expose_in_api = False): + get_roles=all_roles, admin_roles, + expose_in_api = False): if objclass not in taggable_classes: try: @@ -128,7 +130,7 @@ def define_accessors (module, objclass, methodsuffix, tagname, return self.locate_or_create_tag (tagname=tagname, category=category, description=description, - min_role_id=tag_min_role_id) + roles=set_roles) # attach it to the Accessor class setattr(Accessor,locator_name,locate_or_create_tag)