[ckan-dev] Logging and paster post
Sean Hammond
sean.hammond at okfn.org
Fri Jan 11 18:17:27 UTC 2013
Hey, here's a problem that I can't seem to figure out, I'm running an
action function (from an extension) via paster post, like:
echo '{}' | paster --plugin=ckan post -c ../ckan/pdeu.ini /api/action/import_csv2rdf_links
The problem is that I can't get any visibility into the execution of my
code: you can't put in any print statements or set_traces because they
make it crash, and if I try to put in logging nothing appears in the log
file.
In ckanext-pdeu/ckanext/pdeu/plugin.py I've got:
import logging
logger = logging.getLogger(__name__)
and various logger.debug() lines.
(See the whole action function here: https://github.com/okfn/ckanext-pdeu/blob/master/ckanext/pdeu/plugin.py#L107
But nothing gets logged, either from my plugin.py or from ckan core, log
file is not even created.
It seems to be a side-effect of running the action function via paster
post because if I run it by posting to a URL over http, the logging does
work.
But this function is one that takes a very long time and will just
timeout if called that way, hence why I want to call it via paster.
I did first try implementing it as a paster command rather than calling
an action function via paster post, but I got some weirdness from
sqlalchemy:
$ paster pdeu-import-csv2rdf-links
sqlalchemy.exc.UnboundExecutionError: Could not locate a bind configured on mapper Mapper|User|user, SQL expression or this Session
I assume this is similar to something I've seen before: because there's
no Pylons request when running a paster command, some code doesn't work.
Hence using paster post instead, it simulates an http request (I had to
do the same thing for the command that sends out the emails for the
email notification feature in core).
More information about the ckan-dev
mailing list