renaming shortcut into accessor
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Tue, 19 Aug 2008 14:36:06 +0000 (14:36 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Tue, 19 Aug 2008 14:36:06 +0000 (14:36 +0000)
Makefile
PLC/API.py
PLC/Accessors/Factory.py [moved from PLC/Shortcuts/Factory.py with 88% similarity]
PLC/Accessors/Shortcuts_site.py.in [moved from PLC/Shortcuts/Shortcuts_site.py.in with 100% similarity]
PLC/Accessors/Shortcuts_standard.py [moved from PLC/Shortcuts/Shortcuts_standard.py with 89% similarity]
PLC/Accessors/__init__.py [moved from PLC/Shortcuts/__init__.py with 74% similarity]
PLCAPI.spec
setup.py

index 824730f..2df9ee9 100644 (file)
--- 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
index 3c825b7..0710d95 100644 (file)
@@ -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
similarity index 88%
rename from PLC/Shortcuts/Factory.py
rename to PLC/Accessors/Factory.py
index c558ca4..f4dbca8 100644 (file)
@@ -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)
 
similarity index 89%
rename from PLC/Shortcuts/Shortcuts_standard.py
rename to PLC/Accessors/Shortcuts_standard.py
index 5180189..3b6ceae 100644 (file)
@@ -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=[]
 
similarity index 74%
rename from PLC/Shortcuts/__init__.py
rename to PLC/Accessors/__init__.py
index 5c4d0ce..b689130 100644 (file)
@@ -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()
index d1f76cf..15bc967 100644 (file)
@@ -75,6 +75,10 @@ cat > $RPM_BUILD_ROOT/%{_sysconfdir}/php.d/xmlrpc.ini <<EOF
 extension=xmlrpc.so
 EOF
 
+%post
+# create local shortcuts if not present (mentioned in PLC/Shortcuts/__init__.py)
+[ -f %{_datadir}/plc_api/PLC/Accessors/Accessors_site.py ] || cp %{_datadir}/plc_api/PLC/Accessors/Accessors_site.py.in %{_datadir}/plc_api/PLC/Accessors/Accessors_site.py
+
 %clean
 rm -rf $RPM_BUILD_ROOT
 
index f192d80..1e7725d 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -12,7 +12,7 @@ from distutils.core import setup
 from glob import glob
 
 setup(py_modules = ['ModPython'],
-      packages = ['PLC', 'PLC/Methods', 'PLC/Methods/system', 'PLC/Shortcuts', 'PLC/Legacy'],
+      packages = ['PLC', 'PLC/Methods', 'PLC/Methods/system', 'PLC/Accessors', 'PLC/Legacy'],
       scripts = ['plcsh', 'Server.py'],
       data_files = [('', ['planetlab5.sql']),
                     ('php', ['php/plc_api.php']),