From 646b1a34b3e00a78426780e2e677d85e3e1b8924 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Tue, 19 Aug 2008 14:36:06 +0000 Subject: [PATCH] renaming shortcut into accessor --- Makefile | 2 +- PLC/API.py | 8 ++++---- PLC/{Shortcuts => Accessors}/Factory.py | 18 +++++++++--------- .../Shortcuts_site.py.in | 0 .../Shortcuts_standard.py | 2 +- PLC/{Shortcuts => Accessors}/__init__.py | 4 ++-- PLCAPI.spec | 4 ++++ setup.py | 2 +- 8 files changed, 22 insertions(+), 18 deletions(-) rename PLC/{Shortcuts => Accessors}/Factory.py (88%) rename PLC/{Shortcuts => Accessors}/Shortcuts_site.py.in (100%) rename PLC/{Shortcuts => Accessors}/Shortcuts_standard.py (89%) rename PLC/{Shortcuts => Accessors}/__init__.py (74%) diff --git a/Makefile b/Makefile index 824730fe..2df9ee96 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ # $Id$ # -# Metafiles - manage Legacy/ and Shortcuts by hand +# Metafiles - manage Legacy/ and Accessors by hand init := PLC/__init__.py PLC/Methods/__init__.py # python-pycurl and python-psycopg2 avail. from fedora 5 diff --git a/PLC/API.py b/PLC/API.py index 3c825b7a..0710d950 100644 --- a/PLC/API.py +++ b/PLC/API.py @@ -83,7 +83,7 @@ except ImportError: from PLC.Config import Config from PLC.Faults import * import PLC.Methods -import PLC.Shortcuts +import PLC.Accessors import PLC.Legacy def import_deep(name): @@ -99,11 +99,11 @@ class PLCAPI: native_methods = PLC.Methods.native_methods # other_methods_map : dict {methodname: fullpath} - # e.g. 'Shortcuts' -> 'PLC.Shortcuts.Shortcuts' + # e.g. 'Accessors' -> 'PLC.Accessors.Accessors' other_methods_map={} - for subdir in [ 'Shortcuts', 'Legacy']: + for subdir in [ 'Accessors', 'Legacy']: path="PLC."+subdir - # scan e.g. PLC.Shortcuts.__all__ + # scan e.g. PLC.Accessors.__all__ pkg = __import__(path).__dict__[subdir] for modulename in getattr(pkg,"__all__"): fullpath=path+"."+modulename diff --git a/PLC/Shortcuts/Factory.py b/PLC/Accessors/Factory.py similarity index 88% rename from PLC/Shortcuts/Factory.py rename to PLC/Accessors/Factory.py index c558ca4f..f4dbca89 100644 --- a/PLC/Shortcuts/Factory.py +++ b/PLC/Accessors/Factory.py @@ -34,7 +34,7 @@ all_roles = [ 'admin', 'pi', 'tech', 'user', 'node' ] # while get_roles and set_roles get attached to the created methods # # returns a tuple (get_method, set_method) -# See Shortcuts.py for examples +# See Accessors* for examples def get_set_factory (objclass, methodsuffix, tagname, category, description, tag_min_role_id=10, @@ -42,19 +42,19 @@ def get_set_factory (objclass, methodsuffix, if objclass not in taggable_classes: try: - raise PLCInvalidArgument,"PLC.Shortcuts.Factory: unknown class %s"%objclass.__name__ + raise PLCInvalidArgument,"PLC.Accessors.Factory: unknown class %s"%objclass.__name__ except: - raise PLCInvalidArgument,"PLC.Shortcuts.Factory: unknown class ??" + raise PLCInvalidArgument,"PLC.Accessors.Factory: unknown class ??" classname=objclass.__name__ get_name = "Get" + classname + methodsuffix set_name = "Set" + classname + methodsuffix # create method objects under PLC.Method.Method get_class = type (get_name, (Method,), - {"__doc__":"Shortcut 'get' method designed for %s objects using tag %s"%\ + {"__doc__":"Accessor 'get' method designed for %s objects using tag %s"%\ (classname,tagname)}) set_class = type (set_name, (Method,), - {"__doc__":"Shortcut 'set' method designed for %s objects using tag %s"%\ + {"__doc__":"Accessor 'set' method designed for %s objects using tag %s"%\ (classname,tagname)}) # accepts get_accepts = [ Auth () ] @@ -84,8 +84,8 @@ def get_set_factory (objclass, methodsuffix, # body of the get method def get_call (self, auth, id_or_name): - print 'Automagical Shortcut get method',classname,get_name,tagname,primary_key,secondary_key - print 'Warning: PLC/Shortcuts/Factory is an ongoing work' + print 'Automagical Accessor get method',classname,get_name,tagname,primary_key,secondary_key + print 'Warning: PLC/Accessors/Factory is an ongoing work' tag_type_id = locate_or_create_tag_type_id (self.api, tagname, category, description, tag_min_role_id) return 'foobar' @@ -93,8 +93,8 @@ def get_set_factory (objclass, methodsuffix, # body of the set method def set_call (self, auth, id_or_name, tagvalue): - print 'Automagical Shortcut set method',classname,get_name,tagname,primary_key,secondary_key - print 'Warning: PLC/Shortcuts/Factory is an ongoing work' + print 'Automagical Accessor set method',classname,get_name,tagname,primary_key,secondary_key + print 'Warning: PLC/Accessors/Factory is an ongoing work' return None setattr (set_class,"call",set_call) diff --git a/PLC/Shortcuts/Shortcuts_site.py.in b/PLC/Accessors/Shortcuts_site.py.in similarity index 100% rename from PLC/Shortcuts/Shortcuts_site.py.in rename to PLC/Accessors/Shortcuts_site.py.in diff --git a/PLC/Shortcuts/Shortcuts_standard.py b/PLC/Accessors/Shortcuts_standard.py similarity index 89% rename from PLC/Shortcuts/Shortcuts_standard.py rename to PLC/Accessors/Shortcuts_standard.py index 51801896..3b6ceaee 100644 --- a/PLC/Shortcuts/Shortcuts_standard.py +++ b/PLC/Accessors/Shortcuts_standard.py @@ -6,7 +6,7 @@ from PLC.Interfaces import Interface from PLC.Slices import Slice from PLC.Ilinks import Ilink -from PLC.Shortcuts.Factory import all_roles, get_set_factory +from PLC.Accessors.Factory import all_roles, get_set_factory methods=[] diff --git a/PLC/Shortcuts/__init__.py b/PLC/Accessors/__init__.py similarity index 74% rename from PLC/Shortcuts/__init__.py rename to PLC/Accessors/__init__.py index 5c4d0ced..b689130b 100644 --- a/PLC/Shortcuts/__init__.py +++ b/PLC/Accessors/__init__.py @@ -1,5 +1,5 @@ # each module to define in "methods" the set of methods that it defines __all__ = """ -Shortcuts_standard -Shortcuts_site +Accessors_standard +Accessors_site """.split() diff --git a/PLCAPI.spec b/PLCAPI.spec index d1f76cfe..15bc9679 100644 --- a/PLCAPI.spec +++ b/PLCAPI.spec @@ -75,6 +75,10 @@ cat > $RPM_BUILD_ROOT/%{_sysconfdir}/php.d/xmlrpc.ini <