[Zope] logging inside TTW script

Dario Lopez-Kästen dario at ita.chalmers.se
Sun Mar 6 07:54:45 EST 2005


Andreas Jung wrote:
> 
> 
> --On Sonntag, 6. März 2005 13:38 Uhr +0100 Milos Prudek <prudek at bvx.cz> 
> wrote:
> 
>>> Why should logging within a PythonScript (e.g. through zLOG) be
>>> discarded? The zLOG engine is *not* tied to transactions.
>>
>>
>> Thank you Andreas. Could you please post a one-line simplest example of
>> using zLOG in a TTW Python Script ?
>>
> 
> *wink* the zLOG API is documented :-) -> zLOG package
> 
> from zLOG import lOG, INFO
> 
> LOG(ident, INFO, reason)

and enabling zLOG may be an adventure by itself. Try using something 
along this general idea.

request = container.REQUEST
RESPONSE =  request.RESPONSE
write = RESPONSE.write
<...stuff...>

for o in some_objects_somehwere:
   <...more..stuff...>
   write('some_cool_message_like_iter_number')

it will write messages to the page as they are processed, w/o waiting 
for the transaction to commit or finish.

Another way to do things is to create an error_log object in the 
containing folder and see what it logs (you may want to edit the errors 
it omits).

Hope this helps.

/dario

-- 
-- -------------------------------------------------------------------
Dario Lopez-Kästen, IT Systems & Services Chalmers University of Tech.
"...and click? damn, I need to kill -9 Word again..." - b using macosx


More information about the Zope mailing list