2010-06-13 3 views

답변

2

조상 목록을 저장하는 대신 ListProperty (db.Key)를 사용하는 것이 좋습니다. 그런 식으로, 당신은 (쉽게 '노드 X의 모든 자손을 얻을 수')보다 효율적으로 조회 할 수 있습니다, 당신은 다음과 같이 쉽게 후자의 조건을 적용 할 수 있습니다 : 엔티티의 자신의 키에없는 것을

def ancestor_list_validator(l): 
    if len(l) != len(set(l)): 
    raise Exception("Repeated values in ancestor list!") 

class Post(db.Model): 
    # ... 
    ancestors = db.ListProperty(db.Key, validator=ancestor_list_validator) 

검증 목록은 약간 힘들며 custom datastore property을 작성해야 할 가능성이 높습니다.