2011-01-25 35 views
3

我想存儲整數列表(user ids),我應該讓它們成爲字符串並使用StringListProperty,還是隻使用ListProperty,我想知道什麼是更優化的,具體的StringListProperty異構ListProperty(僅與整數一起使用時)。ListProperty與Google App Engine上的StringListProperty

我需要將用戶添加到列表中,直到達到某個數字,然後爲這些用戶(在單獨的實體組中)創建一個組實例。

回答

10

StringListProperty只是ListProperty的一個很薄的包裝。除了元素類型之外沒有任何有意義的區別。

the code itself

class StringListProperty(ListProperty): 
    def __init__(self, verbose_name=None, default=None, **kwds): 
    super(StringListProperty, self).__init__(basestring, 
              verbose_name=verbose_name, 
              default=default, 
              **kwds) 

我建議你存儲在一個普通的ListProperty整數,從此你就可以查詢並正確地排序,即數字,在數據存儲區查詢,你不能輕易做,如果你將它們轉換爲字符串。