oerppy-hackers team mailing list archive
-
oerppy-hackers team
-
Mailing list archive
-
Message #00005
[Branch ~oerppy-hackers/oerppy/trunk] Rev 25: * Simplified a date item in a query.
------------------------------------------------------------
revno: 25
committer: duncan@xxxxxxxxxx
branch nick: trunk
timestamp: Wed 2011-06-01 16:33:25 -0600
message:
* Simplified a date item in a query.
* Added some missing docstrings.
modified:
oerppy/addons/canonical.py
oerppy/service.py
oerppy/util.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 'oerppy/addons/canonical.py'
--- oerppy/addons/canonical.py 2011-06-01 16:42:38 +0000
+++ oerppy/addons/canonical.py 2011-06-01 22:33:25 +0000
@@ -93,13 +93,13 @@
Get the weekly timeentry records, highlighting the missing weeks.
"""
# Get user Ids of timesheet users and the weeks we're interested in
+ today = datetime.date.today()
+ last_week = today - datetime.timedelta(days=-7)
weeks = self.client.searchfields(
'project.timeentry.week',
[
(['week','>','2010-12-31']),
- ('week','<=',
- (datetime.date.today()+datetime.timedelta(days=-7)).isoformat()
- )
+ ('week','<=', last_week.isoformat())
],
[])
user_fields = self.client.searchfields(
=== modified file 'oerppy/service.py'
--- oerppy/service.py 2011-06-01 20:37:05 +0000
+++ oerppy/service.py 2011-06-01 22:33:25 +0000
@@ -163,6 +163,23 @@
self.endpoints, self.dbname, self.credentials)
def __getattr__(self, name):
+ """
+ This bit of "magic" allows us to make client and addon method calls
+ directly on instances of this service class. The lookup order is the
+ following:
+ * check the Service instance for the attribute, then
+ * check the Client instance (self.client), then
+ * check each addon that hass been added to the Client instance
+
+ Here are some examples:
+ * self.dbname returns the value of dbname on the Service instance
+
+ * self.addons isn't found on the Service instance (self) so it
+ check the client; self.client.addons is returned
+
+ * self.query isn't found on self or self.client, so each addon is
+ * checked; if CanonicalAddOns is loaded, it will find
+ """
try:
attrib = super(Service, self).__getattr__(name)
except AttributeError:
=== modified file 'oerppy/util.py'
--- oerppy/util.py 2011-06-01 18:55:24 +0000
+++ oerppy/util.py 2011-06-01 22:33:25 +0000
@@ -86,6 +86,16 @@
def partial(func, *args, **keywords):
+ """
+ By using partial function application, we're able "pre-process" functions
+ whose first few arguments we know ahead of time.
+
+ As used in this project, partial saves us extra lines of code in the form
+ of redundancy removal. We need only "prepare" the functions/methods ahead
+ of time, and then "finish" them at actual execution time, instead of
+ re-calling the original method over and over again with half of the
+ arguments remaining the same every time.
+ """
def newfunc(*fargs, **fkeywords):
newkeywords = keywords.copy()
newkeywords.update(fkeywords)
@@ -94,3 +104,6 @@
newfunc.args = args
newfunc.keywords = keywords
return newfunc
+
+
+