1

I have a Plone site that has a lot of data in it and I would like 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

4

1 回答 1

4

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.

于 2010-04-18T22:56:04.143 回答