- documentation
- Added documentation for the Inspector. [ticket:1820]
-
+
+ - Fixed @memoized_property and @memoized_instancemethod
+ decorators so that Sphinx documentation picks up
+ these attributes and methods, such as
+ ResultProxy.inserted_primary_key. [ticket:1830]
+
+
0.6.1
=====
- orm
consistent across backends.
Usage of this method is normally unnecessary; the
- inserted_primary_key method provides a
+ :attr:`~ResultProxy.inserted_primary_key` attribute provides a
tuple of primary key values for a newly inserted row,
regardless of database backend.
@util.deprecated("Use inserted_primary_key")
def last_inserted_ids(self):
- """deprecated. use inserted_primary_key."""
+ """deprecated. use :attr:`~ResultProxy.inserted_primary_key`."""
return self.inserted_primary_key
def __get__(self, obj, cls):
if obj is None:
- return None
+ return self
obj.__dict__[self.__name__] = result = self.fget(obj)
return result
def __get__(self, obj, cls):
if obj is None:
- return None
+ return self
def oneshot(*args, **kw):
result = self.fget(obj, *args, **kw)
memo = lambda *a, **kw: result
for loads, dumps in picklers():
print loads(dumps(d))
+
+class MemoizedAttrTest(TestBase):
+ def test_memoized_property(self):
+ val = [20]
+ class Foo(object):
+ @util.memoized_property
+ def bar(self):
+ v = val[0]
+ val[0] += 1
+ return v
+
+ ne_(Foo.bar, None)
+ f1 = Foo()
+ assert 'bar' not in f1.__dict__
+ eq_(f1.bar, 20)
+ eq_(f1.bar, 20)
+ eq_(val[0], 21)
+ eq_(f1.__dict__['bar'] , 20)
+
+ def test_memoized_instancemethod(self):
+ val = [20]
+ class Foo(object):
+ @util.memoized_instancemethod
+ def bar(self):
+ v = val[0]
+ val[0] += 1
+ return v
+
+ ne_(Foo.bar, None)
+ f1 = Foo()
+ assert 'bar' not in f1.__dict__
+ eq_(f1.bar(), 20)
+ eq_(f1.bar(), 20)
+ eq_(val[0], 21)
class ColumnCollectionTest(TestBase):
def test_in(self):