pyramid.location
¶
- lineage(resource)[源代码]¶
返回表示 lineage 的 resource 对象所隐含的
resource
参数。发电机首先返回resource
无条件地。然后,如果resource
供应A__parent__
属性,返回由表示的资源resource.__parent__
. 如果 that 资源有__parent__
属性,返回该资源的父级,依此类推,直到被检查的资源没有__parent__
属性或具有__parent__
属性None
. 例如,如果资源树是:thing1 = Thing() thing2 = Thing() thing2.__parent__ = thing1
调用
lineage(thing2)
将返回发电机。当我们把它变成一个列表时,我们会得到:list(lineage(thing2)) [ <Thing object at thing2>, <Thing object at thing1> ]