From 7c075642e87dbf60410f5bda784af7a31a4a12aa Mon Sep 17 00:00:00 2001 From: helmutm Date: Tue, 2 Jun 2009 14:59:18 +0000 Subject: [PATCH] log classifier info instead of printing git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3410 fd906abe-77d9-0310-91a1-e0d9ade77398 --- classifier/README.txt | 12 +++++++++--- classifier/base.py | 9 ++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/classifier/README.txt b/classifier/README.txt index b4a2f24..f35014d 100644 --- a/classifier/README.txt +++ b/classifier/README.txt @@ -131,13 +131,17 @@ that may be identified as being candidates for classification. So we are now ready to have the whole stuff run in one call. >>> classifier.process(r1) - Classifier fileclassifier: Assigning: ... + +Classifier fileclassifier: Assigning: ... + >>> list(sorted([c.title for c in r1.getConcepts()])) [u'Collection One', u'Contract', u'External File', u'Gerald Webb', u'im Editors'] >>> for name in rnames[1:]: ... classifier.process(resources[name]) - Classifier fileclassifier: Assigning: ... + +Classifier fileclassifier: Assigning: ... + >>> len(webbg.getResources()) 4 >>> len(webbg.getResources((concepts['ownedby'],))) @@ -147,7 +151,9 @@ We can repeat the process without getting additional assignments. >>> for name in rnames[1:]: ... classifier.process(resources[name]) - Classifier fileclassifier: Already assigned: ... + +Classifier fileclassifier: Already assigned: ... + >>> len(webbg.getResources()) 4 diff --git a/classifier/base.py b/classifier/base.py index 32c5b17..046850a 100644 --- a/classifier/base.py +++ b/classifier/base.py @@ -23,6 +23,7 @@ $Id$ """ from itertools import tee +from logging import getLogger from zope.cachedescriptors.property import Lazy from zope import component from zope.component import adapts @@ -100,14 +101,16 @@ class Classifier(AdapterBase): resources = concept.getResources([predicate]) if resource not in resources: concept.assignResource(resource, predicate) - message = 'Assigning: %s %s %s' + message = u'Assigning: %s %s %s' else: - message = 'Already assigned: %s %s %s' + message = u'Already assigned: %s %s %s' self.log(message % (resource.title, predicate.title, concept.title), 5) def log(self, message, level=5): if level >= self.logLevel: - print 'Classifier %s:' % getName(self.context), message + #print 'Classifier %s:' % getName(self.context), message + getLogger('Classifier').info( + u'%s: %s' % (getName(self.context), message)) class Extractor(object):