Skip to content

Commit

Permalink
Merge branch 'master' of github.com:marinho/geraldo
Browse files Browse the repository at this point in the history
  • Loading branch information
marinho committed May 6, 2010
2 parents def1238 + 9a4ff09 commit 46aeba9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2010-05-06: Version 0.4.3-stable
--------------------------------
* Fixed cross reference matrix and expressions to avoid use existing object as dictionary

2010-04-29: Version 0.4.2-stable
--------------------------------
* Implemented support to merge default_style to inherite reports
Expand Down
2 changes: 1 addition & 1 deletion geraldo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
- tests - a package with automated doc tests.
"""

VERSION = (0, 4, 2, 'stable')
VERSION = (0, 4, 3, 'stable')

def get_version():
return '%d.%d.%d-%s'%VERSION
Expand Down
23 changes: 13 additions & 10 deletions geraldo/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ def get_object_value(self, instance=None, attribute_name=None):
instance = instance or self.instance
attribute_name = attribute_name or self.attribute_name

# Checks lambda and instance
if self.get_value and instance:
try:
return self.get_value(self, instance)
except TypeError:
return self.get_value(instance)

# Checks this is an expression
tokens = EXP_TOKENS.split(attribute_name)
tokens = filter(bool, tokens) # Cleans empty parts
Expand All @@ -146,13 +153,6 @@ def get_object_value(self, instance=None, attribute_name=None):
values[token] = self.get_object_value(instance, token)
return eval(attribute_name, values)

# Checks lambda and instance
if self.get_value and instance:
try:
return self.get_value(self, instance)
except TypeError:
return self.get_value(instance)

# Gets value with function
value = get_attr_value(instance, attribute_name)

Expand Down Expand Up @@ -235,7 +235,10 @@ def _text(self):
value = getattr(self, 'action_'+self.action)()

if self.get_text:
self._cached_text = unicode(self.get_text(self.instance, value))
try:
self._cached_text = unicode(self.get_text(self, self.instance, value))
except TypeError:
self._cached_text = unicode(self.get_text(self.instance, value))
else:
self._cached_text = unicode(value)

Expand All @@ -261,9 +264,9 @@ def get_value_by_expression(self, expression=None):
if not self.instance:
global_vars = {}
elif isinstance(self.instance, dict):
global_vars = self.instance
global_vars = self.instance.copy()
else:
global_vars = self.instance.__dict__
global_vars = self.instance.__dict__.copy()

global_vars.update({
'value': self.action_value,
Expand Down

0 comments on commit 46aeba9

Please sign in to comment.