Submitted by : strank at: 2007-01-11T23:09:58+00:00 (10 years ago)
Name :
Category : Severity : Status :
Optional subject :  
Optional comment :

zLOG triggers deprecation warnings in Zope >2.9

Below is an updated (2008-08-01) patch to fix this. (It does not touch the plugins directory. mathaction and latexwiki also use zLOG.)

Patch below. I'll leave it ugly as it is for convenient cutting from the source text. Later it should be indented for aesthetic reasons ;-):

MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=_"

Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

Wed Jul 30 09:26:01 Westeurop=E4ische Sommerzeit 2008  strank(AT)strank(DOT=
  * backward-compatibly change from using zLOG to logging

Content-Type: text/x-darcs-patch; name="backward_compatibly-change-from-using-zlog-to-logging.dpatch"
Content-Transfer-Encoding: quoted-printable
Content-Description: A darcs patch for your repository!

New patches:

[backward-compatibly change from using zLOG to logging
strank(AT)strank(DOT)info**20080730072601] {
addfile ./
hunk ./ 6
-#problems.. due to circular import ?
-#from Utils import BLATHER
-#XXX temp
-def BLATHER(t):
-    import zLOG
-    zLOG.LOG('ZWiki',zLOG.BLATHER,t)
+from Logging import BLATHER
hunk ./ 1
+Logging facilities for ZWiki.
+Python 2.3 logging by default, if this fails it uses the deprecated zLOG.
+import sys
+def STDERR(*args):
+    sys.stderr.write(' '.join(map(str,args)) + '\n')
+    import logging
+    logger =3D logging.getLogger('ZWiki')
+    try:
+        # this custom level is used by the deprecated zLOG too
+        # so it might already be present:
+        logging.addLevelName("BLATHER", CUSTOM_BLATHER)
+    except:
+        pass # ignore errors here
+    def DEBUG(*args):
+        logger.debug(' '.join(map(str,args)))
+    def BLATHER(*args):
+        logger.log(CUSTOM_BLATHER, ' '.join(map(str,args)))
+    def INFO(*args):
+' '.join(map(str,args)))
+    def WARN(*args):
+        logger.warning(' '.join(map(str,args)))
+except ImportError:
+    import zLOG
+    def DEBUG(*args):
+        zLOG.LOG('ZWiki', zLOG.DEBUG, ' '.join(map(str,args)))
+    def BLATHER(*args):
+        zLOG.LOG('ZWiki', zLOG.BLATHER, ' '.join(map(str,args)))
+    def INFO(*args):
+        zLOG.LOG('ZWiki', zLOG.INFO, ' '.join(map(str,args)))
+    def WARN(*args):
+        zLOG.LOG('ZWiki', zLOG.WARNING, ' '.join(map(str,args)))
hunk ./ 13
+from Logging import WARN, BLATHER, DEBUG, STDERR, INFO
hunk ./ 589
-def STDERR(*args):  sys.stderr.write(' '.join(map(str,args)) + '\n')
-def BLATHER(*args): zLOG.LOG('ZWiki',zLOG.BLATHER,' '.join(map(str,args)))
-def INFO(*args):    zLOG.LOG('ZWiki',zLOG.INFO,' '.join(map(str,args)))
-def WARN(*args):    zLOG.LOG('ZWiki',zLOG.WARNING,' '.join(map(str,args)))
-def DEBUG(*args):   zLOG.LOG('ZWiki',zLOG.DEBUG,' '.join(map(str,args)))


[make fixperms fix the top directory also
Simon Michael <>**20080514192418] =

[make displaysSubtopicsWithDtml regexp a little smarter
Simon Michael <>**20080508231132] =

[provide x access key only when external edit is available
Simon Michael <>**20080502182412] =

[be more careful when mutating the parents property, to avoid inconsistenci=
es (#1353, Willi Langenberger)**20080502040059] =

[fix an unsafe use of page name which could break editform (#1376, Noboyuku=
 Koyoshi)**20080502033908] =

[fix excerptAt to pass its test**20080502033840] =

[dublin core Creator method now returns the CMF creators property if presen=
t, ignoring Zwiki's creator property (#1302)**20080502020025] =

[remove unused allowed argument
Simon Michael <>**20080501234746] =

[fix /fixAllPagesEncoding, probably**20080502013643] =

[fix the intermittent unicode errors arising from excerpts in search result=
s (#1389)**20080502013447] =

[provide indexObject to avoid revision indexing in plone 3 (#1407, Dorneles=
Simon Michael <>**20080501171817] =

[Added some more functional tests (filling out the options, searching)**20080430181047] =

[make comment's mail-sending optional
Simon Michael <>**20080426212647] =

[style guide cleanups
Simon Michael <>**20080426064426] =

[a basic sphinx doc building setup (easy_install sphinx, make doc)
Simon Michael <>**20080426061304] =

[utf8-encode CHANGES.txt, for Sphinx
Simon Michael <>**20080426051644] =

[add suffix to skins readme
Simon Michael <>**20080426051536] =

[give all doc files a .txt suffix to help tools like Sphinx
Simon Michael <>**20080426045333] =

[remove cruft
Simon Michael <>**20080308193434] =

[make tests pass, move test_excerptAt
Simon Michael <>**20080425211609] =

[the bones of 0.61 release notes
Simon Michael <>**20080411230600] =

[fix the plone 3 document actions display glitch - hide them
Simon Michael <>**20080411223339] =

[make plone member email lookup more robust to fix non-mail-out (#1400)
Simon Michael <>**20080328150941] =

[make lastLog more robust, prevent occasional page breakage
Simon Michael <>**20080308092303] =

[pages now returns nothing without a fully-configured catalog (to avoid blo=
wing up zodb cache when viewing old revisions)
Simon Michael <>**20080311225700] =

[drop the "discussion" nav link activated by GeneralDiscussion, it is a spe=
cial case and confusable with per-page discussion
Simon Michael <>**20080216224956] =

[add nav links to contents form too
Simon Michael <>**20080214205006] =

[don't break showAccessKeys legacy url
Simon Michael <>**20080214204924] =

[add site navigation links to all forms
Simon Michael <>**20080214204402] =

[move access key help to help page
Simon Michael <>**20080214204114] =

[split links macro so we can omit the page-specific nav links on forms
Simon Michael <>**20080214200045] =

[optimise the bottom-quoting regexp a little.. I suspect it's blowing up me=
mory on mailin
Simon Michael <>**20080213123018] =

[More functional tests: recentchanges and options**20080213112039] =

[add the nav links to the help page, testing
Simon Michael <>**20080213112240] =

[more CHANGES updates
Simon Michael <>**20080213110704] =

[strip some bottom-quoting from mailins
Simon Michael <>**20080209035936] =

[include doctest in testsupport
Simon Michael <>**20080209035718] =

[makefile cleanup
Simon Michael <>**20080208173901] =

[replace: subscriberCount, wikiSubscriberCount with: subscriberCount, pageS=
ubscriberCount, wikiSubscriberCount
Simon Michael <>**20080207185156] =

[import latest zwiki-plone translations from launchpad
Simon Michael <>**20080207041102] =

[more translation make rule cleanups
Simon Michael <>**20080207034939] =

[import latest translations from launchpad
Simon Michael <>**20080207034918] =

[switch to i18ndude, regenerate pot file
Simon Michael <>**20080207025001] =

[update makefile translation docs
Simon Michael <>**20080206175636] =

[recognise a site_footer attribute, like site_header, useful for eg stats t=
racking**20080126040833] =

Simon Michael <>**20080125235821] =

[update access key help
Simon Michael <>**20080125235815] =

[remove Makefile's trailing whitespace
Simon Michael <>**20080124165849] =

[include Makefile in tarball so that folks can see how to run tests
Simon Michael <>**20080124165839] =

[Print a note about Functional tests not running <2.10.**20071222191229] =

[Added some functional tests.**20071222185611
 These are implemented using zope.testbrowser, that's why they will
 unfortunately only run on Zope 2.10. The tests basically mimic a browser
 going through some page edits. In that way the tests provide a nice =

 high-level walkthrough. They are using doctest syntax and therefore it's =

 easy to add more. For an overview of the syntax, see:
] =

[1397 - fix revert by re-adding setVotes.**20071222000704
 While rebuilding the rating/voting mechanism I had deleted setVotes()
 since revert() wants to use setVotes() to reset the votes, reverting
 resulted in an ugly traceback.
] =

[doc updates, release notes
Simon Michael <>**20080118162912] =

[1017 - clicking create without pagename gives friendlier error now.**20071126180646
 This probably isn't perfect (user has to click the browsers "back"
 button), but I believe it's much, much better than displaying a
] =

[1352 - remove further (last?) hasattr() calls.**20071117150226
 Since these are in dtml or pt code, we replace them with getattr()
 calls, so we don't have to import our safe_hasattr() here. It would
 be nice if Zope had a built in safe_hasattr().
] =

[962 - Show form on issue pages in HTML markup.**20071117144917] =

[1348 - Quote the redirect URL for the "options" page.**20071105195729
 This is ammending "1348 - Setting useroptions now returns to previous page=
 the URL in a POST variable should be properly quoted. It usually works wit=
hout =

 this, but it's not correct.
] =

[Catch only locale specific errors, no bare except.**20071013183750] =

[1391 - fixed "Footer 'create' button without page name results in Attribut=
 In this case the name of the new page is not entered from the initial =

 "footer" form, but only on the edit/create page.
] =

[more coding style notes
Simon Michael <>**20071104173259] =

[add a doc file overview to README
Simon Michael <>**20071104163944] =

[directory overview & more style notes
Simon Michael <>**20071104164649] =

[move/update some old style docs
Simon Michael <>**20071104154420] =

[start a developer style guide, with some documentation guidelines
Simon Michael <>**20071102174859] =

[clarify that handleEditText permissions check
Simon Michael <>**20071028080428] =

[a little whitespace**20071028062937] =

[make linecounts**20071028062925] =

[Recorded rating change.**20071030110512
 We want to update CHANGES incrementally. Attempting to find a form for
 that here, which at the release could be changed quickly to the final
 release CHANGES.
] =

[Update only rating related indexes in catalog.**20071030085420
 We're saving some bytes by updating only the indexes actually
 related to voting. All metadata will unfortunately be updated anyway.
] =

[Switched to OOBTree for recording ratings.**20071030083921
 Dictionaries on persistant objects in the ZODB can only be saved by
 writing all of the object to the ZODB again. Inefficient. We're using
 a BTree now, which will save us some kB writing to disk and also
 reduces the likelyhood of ConflictErrors on the page.
 On accessting the "votes" we check for old votes still being =

 dictionaries, moving them to BTrees on-the-fly. The overhead for this
 is counterbalanced by easier recording of votes, just set the entry
 in the BTree.
] =

[Remove mentions of purple numbers in comments.**20071029174114] =

[oops! not running tests enough. Two typos and one bugfix**20071028022406] =

[create cleanup. All significant methods in Editing have now been reviewed/=
tightened up.
Simon Michael <>**20071028020234] =

[move methods
Simon Michael <>**20071028014132] =

[comment cleanup**20071028014019] =

[autoSubscriptionEnabled cleanup
Simon Michael <>**20071028011715] =

[append, edit cleanup**20071028011427] =

[handleSubtopicsProperty cleanup
Simon Michael <>**20071028010818] =

[handleEditText cleanup
Simon Michael <>**20071028010617] =

[delete cleanup, drop unused updatebacklinks argument
Simon Michael <>**20071028010321] =

[handleRename cleanup
Simon Michael <>**20071028005220] =

[handleEditPageType cleanup**20071028005122] =

[move a method**20071028004655] =

[revert cleanup**20071026162019] =

[setCreatorLike, setLastEditorLike**20071026162005] =

[tests for new expunge methods**20071026160319] =

[clarification**20071026160308] =

[handy new manager methods expungeLastEditor, expungeLastEditorEverywhere; =
expunge, expungeEditsEverywhereBy cleanup**20071026150936] =

[#1393 Catch ValueError too on importing unknown pagetypes.**20071022074304] =

[PUT cleanup
Simon Michael <>**20071019053515] =

[file upload code cleanup**20071018022343] =

[rename cleanup**20071017125051] =

[cleanupText cleanup**20071017123631] =

[clean up subtopicsEnabled**20071016174006] =

[make bare page rendering at the debug prompt work again, cleanup**20071016172335] =

[Catch only AttributeError for self.DestinationURL().**20071013191137] =

[removed some unused code in
Simon Michael <>**20071013190549] =

[os.mkdir will raise OSError, removed bare except.**20071013184205] =

[Zope version path changed in >=3D2.9, bare except removed.**20071013171756] =

[notes update**20071010163932] =

[Catch only AttributeError instead of bare except clause (in old fix for #1=
137).**20071003184029] =

[Fix test_setupDtmlMethods for sitemap.xml.dtml.**20071003183255] =

[Change content-type of the SomePage/text (or /src) methods to UTF-8.**20071009085748
 Makes the /text view of wiki pages much more usefull for non-ascii languag=
] =

[wording**20071010150624] =

[a google sitemap.xml, installed by setupDtmlMethod.. may reduce load from =
search bots**20070927201735] =

[remove the anti-spam 24 hour indexing delay introduced in 0.41, for better
Simon Michael <>**20070925161611
  indexing of actively-edited pages (#1387)
] =

Simon Michael <>**20070924165908] =

[upgrade notes
Simon Michael <>**20070920192543] =

[more upgrade notes
Simon Michael <>**20070920190255] =

[clean up and add summary & upgrade notes for 0.60**20070920185128] =

[convert recent relnote headings to definition lists like the rest**20070920182235] =

[merge rc notes, add headings**20070920181617] =

[mailin test comment**20070919175328] =

[rename changes_rss to edits_rss (with a backwards compatibility alias) and**20070918152135
 update the docstring. Also, test forwarding to the PatchDiscussion page.
] =

[keep any text/x-darcs-patch part, as well as the first text/plain part of =
a mailin**20070919060849] =

[fix darcs patch mailin test**20070919055056] =

[test mailin of a darcs patch**20070918164333] =

[1272 - create PageBrain only for Zwiki Pages.**20070917193709
 Since we are now ensuring that there is always a catalog in a Zwiki,
 the method metadataFor() shouldn't be needed any more. But I'm still
 adding this patch (credits and thanks to koegler), in case some code
 hits on it in the time between an upgrade and running the /upgradeAll
] =

[TAG release-0-60-0**20070915222130] =

Patch bundle hash:



might not be deprecated much longer --betabug, Tue, 20 Feb 2007 13:03:03 +0000 reply

Looking at this thread it looks like zLOG might not be deprecated much longer, since it's just a wrapper around the python logging module anyway. I don't think spending hours removing zLOG.LOG calls from ZWiki code is worth it - we would likely just be replacing it with another wrapper around the python logging module. Any reasons for really doing the change?

indeed, zLOG is undeprecated now --betabug, Tue, 20 Feb 2007 13:30:11 +0000 reply

See "Undeprecated 'zLOG', which will remain a backward-compatibility shim for the Python logging module.".

zLOG is undeprecated, closing --betabug, Mon, 17 Sep 2007 11:53:48 -0700 reply

Status: open => closed

zLOG is undeprecated, closing --simon, Thu, 20 Sep 2007 09:26:09 -0700 reply

I don't know, it might be worth doing, simply for cleanliness and consistency with modern zope code. Especially since there is a nice darcs patch here that claims to take care of it. I might try this later.

zLOG is undeprecated, closing --simon, Thu, 20 Sep 2007 09:33:30 -0700 reply

On the other hand: the patch doesn't apply (Bad patch bundle - I don't know why, it looks perfect). And it will conflict with more recent cleanups to the BLATHER, INFO etc. Better to just use it as inspiration.

thanks --simon, Thu, 20 Sep 2007 09:34:25 -0700 reply

Thanks Stefan! Sorry I missed it at the time.

... --simon, Thu, 20 Sep 2007 09:40:32 -0700 reply

Severity: normal => minor

... --strank, Fri, 01 Aug 2008 02:37:21 -0700 reply

Status: closed => open

patch updated, should apply --strank, Fri, 01 Aug 2008 02:39:20 -0700 reply

I updated the patch (did also send via darcs but it does not show up on GeneralDiscussion). As Simon states above, I also think it should be applied even if zLOG is now undeprecated since it separates concerns in the code and gets rid of duplication.