开发者

How to Access Data in ZODB

I have a Plone site that has a lot of data in it and I would like 开发者_C百科to query the database for usage statistics; ie How many cals with more than 1 entries, how many blogs per group with entries after a given date, etc.

I want to run the script from the command line... something like so:

bin/instance [script name]

I've been googling for a while now but can't find out how to do this.

Also, can anybody provide some help on how to get user specific information. Information like, last logged in, items created.

Thanks! Eric


In general, you can query the portal_catalog to locate content by searching various indexes. See http://plone.org/documentation/manual/developer-manual/indexing-and-searching/querying-the-catalog and http://docs.zope.org/zope2/zope2book/SearchingZCatalog.html for an introduction to the catalog.

In some cases the built-in indexes will allow you to do the query you want. In other cases you may need to write some Python to narrow down the results after doing an initial catalog query.

If you put your querying code in a file called foo.py, you can run it via:

bin/instance run foo.py

Within foo.py, you can refer to the root of the database as 'app'. The catalog would then be found at app.site.portal_catalog, where 'site' is the id of your Plone site.

Finding information about users happens via a separate API (for the Pluggable Auth Service). I'd suggest asking a separate question about that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜