summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext/hybrid.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-08-06 18:53:22 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-08-06 18:53:22 -0400
commit6519b0c72cbae6778eff026815cc2b93cfeeabdf (patch)
treef13c7ae8ee1341a4a05c5b95209a34489a6889c0 /lib/sqlalchemy/ext/hybrid.py
parentc2700941f752963520bf66123cd3467ff4d742ad (diff)
downloadsqlalchemy-6519b0c72cbae6778eff026815cc2b93cfeeabdf.tar.gz
- at long last have gotten the "proxy_property" keyword
arg of register_descriptor to not be needed. synonym, comparable, concreteinherited props now supply a descriptor directly in the class dict, whose __get__(None, cls) supplies a QueryableAttribute. The basic idea is that the hybrid prop can be used for this. Payoff here is arguable, except that hybrid can be at the base of future synonym/comparable operations.
Diffstat (limited to 'lib/sqlalchemy/ext/hybrid.py')
-rw-r--r--lib/sqlalchemy/ext/hybrid.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/sqlalchemy/ext/hybrid.py b/lib/sqlalchemy/ext/hybrid.py
index 2432ec9d7..3134db12d 100644
--- a/lib/sqlalchemy/ext/hybrid.py
+++ b/lib/sqlalchemy/ext/hybrid.py
@@ -62,11 +62,12 @@ or as the class itself::
### TODO ADD EXAMPLES HERE AND STUFF THIS ISN'T FINISHED ###
"""
+from sqlalchemy import util
class method(object):
def __init__(self, func, expr=None):
self.func = func
- self.expr = expr or fund
+ self.expr = expr or func
def __get__(self, instance, owner):
if instance is None:
@@ -78,16 +79,17 @@ class method(object):
self.expr = expr
return self
-class property(object):
+class property_(object):
def __init__(self, fget, fset=None, fdel=None, expr=None):
self.fget = fget
self.fset = fset
self.fdel = fdel
self.expr = expr or fget
-
+ util.update_wrapper(self, fget)
+
def __get__(self, instance, owner):
if instance is None:
- return self.expr(owner)
+ return util.update_wrapper(self.expr(owner), self)
else:
return self.fget(instance)
@@ -109,3 +111,4 @@ class property(object):
self.expr = expr
return self
+