我正在使用flask和redis。我决定尝试使用redis orm(http://pythonhosted.org/rom/)来管理一些稍微复杂的数据结构。我有对象的列表,让说:将所有python-rom对象放入列表中
urls = ['www.google.com', 'www.example.com', 'www.python.org']
我也有ROM模型:
class Stored_url(rom.Model):
url = rom.String(required=True, unique=True, suffix=True)
salt = rom.String()
hash = rom.String()
created_at = rom.Float(default=time.time)
这似乎是工作在我的dev的设置。我已将大约25个'Stored_url'对象加载到REDIS中(在cmd行确认)。我试图想出一种将所有Stored_url类型的对象放入python列表的方法。
>>> test = Mymodels.Stored_url
>>> type(test)
Out[35]: rom._ModelMetaclass
>>> h =test.query.filter(url ='.').all()
>>> h.count()
Traceback (most recent call last):
File "C:\envs\virtalenvs\flaskenv\lib\site-packages\IPython\core\interactiveshell.py", line 3035, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-37-43f0dc233d70>", line 1, in <module>
h.count()
TypeError: count() takes exactly one argument (0 given)
我以为h会有一个对象列表。我究竟做错了什么? (我过滤的是“。”,因为我想通过网址获得)
非常感谢Josiah。 – user61629