Skip to content

Commit

Permalink
Fixed ObjectValue when run a circular reference with expressions like…
Browse files Browse the repository at this point in the history
… 'name.upper'
  • Loading branch information
marinho committed Apr 13, 2010
1 parent a156cc2 commit 4b2533e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGES
@@ -1,3 +1,7 @@
2010-04-11: Version 0.4-alpha-28
--------------------------------
* Fixed ObjectValue when run a circular reference with expressions like 'name.upper'

2010-04-11: Version 0.4-alpha-27
--------------------------------
* Fixed charts on summarize
Expand Down
2 changes: 1 addition & 1 deletion geraldo/__init__.py
Expand Up @@ -31,7 +31,7 @@
- tests - a package with automated doc tests.
"""

VERSION = (0, 4, 'alpha-27')
VERSION = (0, 4, 'alpha-28')

def get_version():
return '%d.%d-%s'%VERSION
Expand Down
6 changes: 4 additions & 2 deletions geraldo/tests/28-expressions.txt
Expand Up @@ -70,7 +70,9 @@ Report class
... ObjectValue(expression='weight', left=3.5*cm),
... ObjectValue(expression='age * weight', left=5*cm),
... ObjectValue(expression='age**2', left=6.5*cm),
... ObjectValue(expression='age * weight ** 2', left=9.5*cm),
... ObjectValue(attribute_name='name.upper', left=8*cm),
... #ObjectValue(expression='name.upper[:3]', left=8*cm), TODO
... ObjectValue(expression='age * weight ** 2', left=10.5*cm),
... ]
...
... class band_summary(DetailBand):
Expand All @@ -83,7 +85,7 @@ Report class
... ObjectValue(expression='sum(age)', left=5*cm),
... ObjectValue(expression='avg(weight)', left=6.5*cm),
... ObjectValue(expression='distinct_count(genre)', left=8*cm),
... ObjectValue(expression='sum(age * weight ** 2)', left=9.5*cm),
... ObjectValue(expression='sum(age * weight ** 2)', left=10.5*cm),
... ]
...
... #groups = [
Expand Down
3 changes: 2 additions & 1 deletion geraldo/widgets.py
Expand Up @@ -79,7 +79,7 @@ def clone(self):
return new

EXP_QUOTED = re.compile('\(([^\'"].+?[^\'"])\)')
EXP_TOKENS = re.compile('(\W+|\*\*|\+|\-|\*|\/)')
EXP_TOKENS = re.compile('([\w\._]+|\*\*|\+|\-|\*|\/)')

class ObjectValue(Label):
"""This shows the value from a method, field or property from objects got
Expand Down Expand Up @@ -132,6 +132,7 @@ def get_object_value(self, instance=None, attribute_name=None):

# Checks this is an expression
tokens = EXP_TOKENS.split(attribute_name)
tokens = filter(bool, tokens) # Cleans empty parts
if len(tokens) > 1:
values = {}
for token in tokens:
Expand Down

0 comments on commit 4b2533e

Please sign in to comment.