1
我尝试继承财产NDB如下面的例子是否可以从属性中获取模型名称和字段名称?
class FileStorageProperty(ndb.StringProperty):
def __init__(self, **kwds):
super(FileStorageProperty, self).__init__(**kwds)
def _to_base_type(self, value):
# Do somethings to get field name and model name
return None
def _from_base_type(self, value):
return None
这样的方式使用FileStorageProperty是出头像
class A(ndb.Model):
file = FileStorageProperty()
我希望做的是,FileStorageProperty类如内。 init,_to_base_type,_from_base_type我想知道模型名称('A')和字段名称('文件')。
谢谢你的任何建议。
FileStorage Class在哪里?在你的例子中只有FileStorageProperty类,不清楚你想要什么:) – linpingta
为我的错误道歉,我的意思是在FileStorageProperty类中。我只是编辑问题以便更好地理解。 – Chetchaiyan
您不能..因为您正在为另一个类A内的FileStorageProperty类创建对象,那么如何让A类在FileStorageProperty类中可用。双向的方式是不可能的。 –