diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-01-12 15:35:20 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-01-12 15:35:20 -0500 |
commit | c9ebe3b723ecc17bb171343f05534f4fd7c9a9fc (patch) | |
tree | 4a01012b4c81d2b1cf57d179d8f903f1de95d54c /lib/sqlalchemy/ext/hybrid.py | |
parent | be4e6d4cd515dd91370a5944fa4dab70a8de206b (diff) | |
download | sqlalchemy-c9ebe3b723ecc17bb171343f05534f4fd7c9a9fc.tar.gz |
- rename hybrid.property_, hybrid.method to hybrid_property, hybrid_method. more typing
on the import but this is just clearer.
- adapt dictlike-polymorphic.py to use hybrid.
Diffstat (limited to 'lib/sqlalchemy/ext/hybrid.py')
-rw-r--r-- | lib/sqlalchemy/ext/hybrid.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/sqlalchemy/ext/hybrid.py b/lib/sqlalchemy/ext/hybrid.py index f3989a84d..9fb8a27d8 100644 --- a/lib/sqlalchemy/ext/hybrid.py +++ b/lib/sqlalchemy/ext/hybrid.py @@ -31,22 +31,22 @@ or as the class itself:: # A base class for intervals - from sqlalchemy.orm import hybrid + from sqlalchemy.orm.hybrid import hybrid_property, hybrid_method class Interval(object): def __init__(self, start, end): self.start = start self.end = end - @hybrid.property + @hybrid_property def length(self): return self.end - self.start - @hybrid.method + @hybrid_method def contains(self,point): return (self.start <= point) & (point < self.end) - @hybrid.method + @hybrid_method def intersects(self, other): return self.contains(other.start) | self.contains(other.end) @@ -56,7 +56,7 @@ or as the class itself:: from sqlalchemy import util from sqlalchemy.orm import attributes, interfaces -class method(object): +class hybrid_method(object): def __init__(self, func, expr=None): self.func = func self.expr = expr or func @@ -71,7 +71,7 @@ class method(object): self.expr = expr return self -class property_(object): +class hybrid_property(object): def __init__(self, fget, fset=None, fdel=None, expr=None): self.fget = fget self.fset = fset @@ -107,7 +107,7 @@ class property_(object): proxy_attr = attributes.\ create_proxied_attribute(self) def expr(owner): - return proxy_attr(self.__name__, self, comparator(owner)) + return proxy_attr(owner, self.__name__, self, comparator(owner)) self.expr = expr return self |