summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorChris Withers <chris@simplistix.co.uk>2010-02-23 17:17:08 +0000
committerChris Withers <chris@simplistix.co.uk>2010-02-23 17:17:08 +0000
commit165eda57336afd2fcc205a07bed662e021c81861 (patch)
treead9c82a235ec32f474832803b8c975a735c9cc1d /lib/sqlalchemy
parentda4d8dd69867f184347606284f1d4426facafe31 (diff)
downloadsqlalchemy-165eda57336afd2fcc205a07bed662e021c81861.tar.gz
a handy @classproperty decorator
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/util.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/sqlalchemy/util.py b/lib/sqlalchemy/util.py
index 873243de1..97270004b 100644
--- a/lib/sqlalchemy/util.py
+++ b/lib/sqlalchemy/util.py
@@ -1639,3 +1639,13 @@ def _decorate_with_warning(func, wtype, message, docstring_header=None):
decorated = warned(func)
decorated.__doc__ = doc
return decorated
+
+class classproperty(property):
+ """A decorator that behaves like @property except that operates
+ on classes rather than instances.
+
+ This is helpful when you need to compute __table_args__ and/or
+ __mapper_args__ when using declarative."""
+ def __get__(desc, self, cls):
+ return desc.fget(cls)
+