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)
+
eq_(set(util.class_hierarchy(A)), set((A, B, object)))
# end Py2K
+
+class TestClassProperty(TestBase):
+
+ def test_simple(self):
+
+ from sqlalchemy.util import classproperty
+
+ class A(object):
+ something = {'foo':1}
+
+ class B(A):
+
+ @classproperty
+ def something(cls):
+ d = dict(super(B,cls).something)
+ d.update({'bazz':2})
+ return d
+
+ eq_(B.something,{
+ 'foo':1,
+ 'bazz':2,
+ })