How to print in a .cpy file (python) ? I'm using Zope/Plone and I've just started with Python. I've tried this
import logging
logger = logging.getLogger()
logger.info("hello plone")
But it doesn't work.
Thank you for your answer
How to print in a .cpy file (python) ? I'm using Zope/Plone and I've just started with Python. I've tried this
import logging
logger = logging.getLogger()
logger.info("hello plone")
But it doesn't work.
Thank you for your answer
"It doesnt' work" is awfully vague, but your problem is probably a violation of the security sandbox imposed on Python used in scripts that may be edited through the web. "Restricted Python" limits your imports to modules that have been audited to assure that they don't have nasty side effects -- like dumping noise into logs. See http://wiki.zope.org/zope2/PythonScripts for details on Restricted Python.
The general solution to this kind of problem is to build your functionality in unrestricted Python in a Python package. A Zope named utility is the usual mechanism for providing this kind of functionality, and you'll be able to reach the utility's operations from restricted Python by traversing to the named utility.
The answer above means that you cannot import any modules in RestrictedPython scripts which are through-the-web editable Plone scripts. These scripts have end-user permissions, so they are not allowed to run arbitrary Python code.
http://collective-docs.readthedocs.org/en/latest/security/sandboxing.html
You can use context.plone_log("mystring")
style logging in restricted python scripts for logging purposes.