← Back to team overview

oerppy-hackers team mailing list archive

[Branch ~oerppy-hackers/oerppy/trunk] Rev 28: Restructured the addon subpackge directory and file layout.

 

------------------------------------------------------------
revno: 28
committer: duncan@xxxxxxxxxx
branch nick: trunk
timestamp: Thu 2011-06-02 09:49:02 -0600
message:
  Restructured the addon subpackge directory and file layout.
added:
  oerppy/addons/canonical/
  oerppy/addons/canonical/__init__.py
  oerppy/addons/canonical/scripting/
  oerppy/addons/canonical/scripting/__init__.py
renamed:
  oerppy/addons/canonical.py => oerppy/addons/canonical/query.py
  oerppy/addons/tests/ => oerppy/addons/canonical/tests/
  oerppy/scripting/export.py => oerppy/addons/canonical/scripting/export.py
modified:
  bin/export_month_timesheets
  oerppy/scripting/base.py
  oerppy/service.py
  oerppy/addons/canonical/scripting/export.py


--
lp:oerppy
https://code.launchpad.net/~oerppy-hackers/oerppy/trunk

Your team oerppy Hackers is subscribed to branch lp:oerppy.
To unsubscribe from this branch go to https://code.launchpad.net/~oerppy-hackers/oerppy/trunk/+edit-subscription
=== modified file 'bin/export_month_timesheets'
--- bin/export_month_timesheets	2011-06-02 15:16:11 +0000
+++ bin/export_month_timesheets	2011-06-02 15:49:02 +0000
@@ -1,15 +1,15 @@
 #!/usr/bin/env python
-from oerppy.addons import canonical
+from oerppy.addons.canonical import query
+from oerppy.addons.canonical.scripting import export
 from oerppy.config import get_config_data
 from oerppy.reg import registry
-from oerppy.scripting import export
 
 
 # get configuration; note that option parsing is handled by the script
 # class(es)
 config_data = get_config_data()
 # setup any addons that we want
-registry.add("canonical", canonical.CanonicalAddOns)
+registry.add("canonical", query.CanonicalAddOns)
 # run the exporter
 monthly_export = export.Monthly(config_data)
 monthly_export.run()

=== added directory 'oerppy/addons/canonical'
=== added file 'oerppy/addons/canonical/__init__.py'
=== renamed file 'oerppy/addons/canonical.py' => 'oerppy/addons/canonical/query.py'
=== added directory 'oerppy/addons/canonical/scripting'
=== added file 'oerppy/addons/canonical/scripting/__init__.py'
=== renamed file 'oerppy/scripting/export.py' => 'oerppy/addons/canonical/scripting/export.py'
--- oerppy/scripting/export.py	2011-06-01 18:49:40 +0000
+++ oerppy/addons/canonical/scripting/export.py	2011-06-02 15:49:02 +0000
@@ -26,15 +26,6 @@
     """
     Generate an export of a given month's timesheet data.
     """
-    def __init__(self, config_data):
-        self.set_service(config_data)
-        # XXX get the month for the timesheet from the options
-        self.month = options.month
-        # XXX get the year for the timesheet from the options
-        self.year = options.year
-        # XXX get the output file from the options
-        self.output_filename = options.output_filename
-
     def get_option_parser(self):
         """
         Options common to all export classes.
@@ -58,6 +49,10 @@
         user = server_config.get("username")
         password = server_config.get("password")
         self.service = service.Service(url, options.dbname, user, password)
+        # note that we could add the addon (self) to the registry at this
+        # point, but we'd have to hard code a name here, as opposed to how it's
+        # currently done (the executable setting the name associated with the
+        # addon when it's added to the registry).
 
     def run(self):
         data = self.service.get_monthly_timesheets(self.month, self.year)

=== renamed directory 'oerppy/addons/tests' => 'oerppy/addons/canonical/tests'
=== modified file 'oerppy/scripting/base.py'
--- oerppy/scripting/base.py	2011-06-01 18:49:40 +0000
+++ oerppy/scripting/base.py	2011-06-02 15:49:02 +0000
@@ -5,6 +5,16 @@
     """
     The common code for all scripting classes.
     """
+    def __init__(self, config_data):
+        self.service = None
+        self.set_service(config_data)
+
+    def set_service(self, config_data):
+        """
+        This method needs to be implemented by all scripting classes.
+        """
+        raise NotImplementedError("Method implementation missing!")
+
     def get_option_parser(self):
         """
         Options common to all scripts.

=== modified file 'oerppy/service.py'
--- oerppy/service.py	2011-06-02 15:16:11 +0000
+++ oerppy/service.py	2011-06-02 15:49:02 +0000
@@ -179,10 +179,13 @@
 
             * self.query isn't found on self or self.client, so each addon is
               checked (in the order that they were added to the registry, so
-              add your most important ones first)
+              add your most important ones first); depending upon which addons
+              you have loaded, the first one with a "query" method will be
+              returned.
 
-        If you have overlap between the addons methods, then you should call
-        the method directly on the addon. See the docstring for
+        If you have overlap between the addon methods (i.e., addons with
+        methods in common that you want to be able to call), then you should
+        call the method directly on the addon. See the docstring for
         Service.get_addon for more information.
         """
         try: