Skip to content

Commit

Permalink
Fixed expression to support get_value and children methods (like attr…
Browse files Browse the repository at this point in the history
…ibute_name)
  • Loading branch information
marinho committed Apr 19, 2010
1 parent ff2f391 commit df7bced
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2010-04-18: Version 0.4-alpha-30
--------------------------------
* Fixed expression to support get_value and children methods (like attribute_name)

2010-04-16: Version 0.4-alpha-29
--------------------------------
* Fixed on_new_page to support real current page number, instead of internal number (thanks to Ari Caldeira)
Expand Down
2 changes: 1 addition & 1 deletion geraldo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
- tests - a package with automated doc tests.
"""

VERSION = (0, 4, 'alpha-29')
VERSION = (0, 4, 'alpha-30')

def get_version():
return '%d.%d-%s'%VERSION
Expand Down
5 changes: 3 additions & 2 deletions geraldo/tests/28-expressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ Report class
... height = 0.7*cm
... elements = [
... ObjectValue(attribute_name='name'),
... ObjectValue(expression='age,', left=2*cm),
... ObjectValue(expression='age', left=2*cm),
... ObjectValue(expression='weight', left=3.5*cm),
... ObjectValue(expression='age * weight', left=5*cm),
... ObjectValue(expression='age**2', left=6.5*cm),
... ObjectValue(attribute_name='name.upper', left=8*cm),
... ObjectValue(expression='name.upper', left=8*cm),
... #ObjectValue(expression='name.upper[:3]', left=8*cm), TODO
... ObjectValue(expression='age * weight ** 2', left=10.5*cm),
... ObjectValue(expression='name', left=12*cm, get_value=lambda self, inst: 'X'),
... ]
...
... class band_summary(DetailBand):
Expand Down
7 changes: 6 additions & 1 deletion geraldo/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ def prepare_expression(self):

while True:
f = EXP_QUOTED.findall(self.expression)
if not f: break
if not f:
# Replace simple attribute name or method to value("")
if '(' not in self.expression:
self.expression = 'value("%s")' % self.expression
break

self.expression = EXP_QUOTED.sub('("%s")'%(f[0]), self.expression, 1)

Expand Down Expand Up @@ -258,6 +262,7 @@ def get_value_by_expression(self, expression=None):
global_vars = self.instance.__dict__

global_vars.update({
'value': self.action_value,
'count': self.action_count,
'avg': self.action_avg,
'min': self.action_min,
Expand Down

0 comments on commit df7bced

Please sign in to comment.