0
でスーパークラスからプロパティ名を取得するにはどのように私は上記のコメントで示されているようには、サブクラスのpython
class Paginator(object):
@cached_property
def count(self):
some_implementation
class CachingPaginator(Paginator):
def _get_count(self):
if self._count is None:
try:
key = "admin:{0}:count".format(hash(self.object_list.query.__str__()))
self._count = cache.get(key, -1)
if self._count == -1:
self._count = self.count # Here, I want to get count property in the super-class, this is giving me -1 which is wrong
cache.set(key, self._count, 3600)
except:
self._count = len(self.object_list)
count = property(_get_count)
の下のようなクラスは、
self._count = <expression>
がスーパークラスのCountプロパティを取得する必要があります。メソッドの場合は、
super(CachingPaginator,self).count()
AFAIKのように呼び出すことができます。私はSOの中で多くの質問をしてきましたが、それは私を助けませんでした。誰もがこれで私を助けることができますか?
と
をそして、あなたは 'スーパー(CachingPaginator、自己).count'を試してみましたか? –
もしあなたがpython 3であれば: 'super()。count' –
@TheBrewmaster私はPython 2.7のメイトです... –