我有一個瀏覽器認爲它調用方法是這樣的:aq_inner(和朋友)在敏捷的環境中仍然需要嗎?
def __call__(self):
context = aq_inner(self.context)
parent = aq_parent(context).
...
開頭放置一個PDB和玩似乎,對於敏捷也沒有必要使用它,是這樣嗎?
ipdb> self.context, id(self.context), self.context.__class__
(<Container at /plone/ausgaben>, 4651890160, <class 'plone.dexterity.content.Container'>)
ipdb> aq_inner(self.context), id(aq_inner(self.context)), aq_inner(self.context).__class__
(<Container at /plone/ausgaben>, 4651890160, <class 'plone.dexterity.content.Container'>)
所以結果是相同的使用aq_inner或不。
所以問題是:靈巧(作爲self.context和我們的項目實際上一切都是基於靈活性的)防止我們不得不用aq_inner和aq_parent等來包裝所有東西,而是直接使用對象或__parent__
指針?
我懷疑你會看到與id(aq_base(self.context))顯着不同的東西。很確定敏捷對象是aq包裝的。 – sdupton 2014-09-02 15:38:41
事實上,''aq_base''有一個不同的id,並且它的__name__沒有路徑,但問題仍然沒有得到解答:在敏捷環境中,我可能忘記必須使用aq_inner和朋友嗎? – gforcada 2014-09-02 22:05:34
猜測包裝是簡單/一致的,以至於不需要aq_inner,但請記住'__parent__'指針需要採集包裝器,而不是其他方法 - IIRC'assert getattr(aq_base(self.context ),'__parent__',None)是None'。 – sdupton 2014-09-03 04:17:39