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 ;-):

DarcsURL: http://zwiki.org/repos/ZWiki
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=
)info
  * 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 ./Logging.py
hunk ./I18n.py 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 ./Logging.py 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')
+
+try:
+    import logging
+
+    logger =3D logging.getLogger('ZWiki')
+    CUSTOM_BLATHER =3D 15
+    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):
+        logger.info(' '.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 ./Utils.py 13
-import zLOG # LOG,ERROR,INFO,WARNING,BLATHER,DEBUG
+from Logging import WARN, BLATHER, DEBUG, STDERR, INFO
hunk ./Utils.py 589
-#logging
-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)))
-
}

Context:

[make fixperms fix the top directory also
Simon Michael <simon@joyful.com>**20080514192418] =

[make displaysSubtopicsWithDtml regexp a little smarter
Simon Michael <simon@joyful.com>**20080508231132] =

[provide x access key only when external edit is available
Simon Michael <simon@joyful.com>**20080502182412] =

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

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

[fix excerptAt to pass its test
simon@joyful.com**20080502033840] =


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

[remove unused allowed argument
Simon Michael <simon@joyful.com>**20080501234746] =

[fix /fixAllPagesEncoding, probably
simon@joyful.com**20080502013643] =

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

[provide indexObject to avoid revision indexing in plone 3 (#1407, Dorneles=
 Tremea)
Simon Michael <simon@joyful.com>**20080501171817] =

[Added some more functional tests (filling out the options, searching)
betabug.darcs@betabug.ch**20080430181047] =

[make comment's mail-sending optional
Simon Michael <simon@joyful.com>**20080426212647] =

[style guide cleanups
Simon Michael <simon@joyful.com>**20080426064426] =

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

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

[add suffix to skins readme
Simon Michael <simon@joyful.com>**20080426051536] =

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

[remove cruft
Simon Michael <simon@joyful.com>**20080308193434] =

[make tests pass, move test_excerptAt
Simon Michael <simon@joyful.com>**20080425211609] =

[the bones of 0.61 release notes
Simon Michael <simon@joyful.com>**20080411230600] =

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

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

[make lastLog more robust, prevent occasional page breakage
Simon Michael <simon@joyful.com>**20080308092303] =

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

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

[add nav links to contents form too
Simon Michael <simon@joyful.com>**20080214205006] =

[don't break showAccessKeys legacy url
Simon Michael <simon@joyful.com>**20080214204924] =

[add site navigation links to all forms
Simon Michael <simon@joyful.com>**20080214204402] =

[move access key help to help page
Simon Michael <simon@joyful.com>**20080214204114] =

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

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

[More functional tests: recentchanges and options
betabug.darcs@betabug.ch**20080213112039] =

[add the nav links to the help page, testing
Simon Michael <simon@joyful.com>**20080213112240] =

[more CHANGES updates
Simon Michael <simon@joyful.com>**20080213110704] =

[strip some bottom-quoting from mailins
Simon Michael <simon@joyful.com>**20080209035936] =

[include doctest in testsupport
Simon Michael <simon@joyful.com>**20080209035718] =

[makefile cleanup
Simon Michael <simon@joyful.com>**20080208173901] =

[replace: subscriberCount, wikiSubscriberCount with: subscriberCount, pageS=
ubscriberCount, wikiSubscriberCount
Simon Michael <simon@joyful.com>**20080207185156] =

[import latest zwiki-plone translations from launchpad
Simon Michael <simon@joyful.com>**20080207041102] =

[more translation make rule cleanups
Simon Michael <simon@joyful.com>**20080207034939] =

[import latest translations from launchpad
Simon Michael <simon@joyful.com>**20080207034918] =

[switch to i18ndude, regenerate pot file
Simon Michael <simon@joyful.com>**20080207025001] =

[update makefile translation docs
Simon Michael <simon@joyful.com>**20080206175636] =

[recognise a site_footer attribute, like site_header, useful for eg stats t=
racking
simon@joyful.com**20080126040833] =

[whitespace
Simon Michael <simon@joyful.com>**20080125235821] =

[update access key help
Simon Michael <simon@joyful.com>**20080125235815] =

[remove Makefile's trailing whitespace
Simon Michael <simon@joyful.com>**20080124165849] =

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

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

[Added some functional tests.
betabug.darcs@betabug.ch**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:
 SOFTWARE_HOME/zope/testbrowser/README.txt
] =

[1397 - fix revert by re-adding setVotes.
betabug.darcs@betabug.ch**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 <simon@joyful.com>**20080118162912] =

[1017 - clicking create without pagename gives friendlier error now.
betabug.darcs@betabug.ch**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
 traceback.
] =

[1352 - remove further (last?) hasattr() calls.
betabug.darcs@betabug.ch**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.
betabug.darcs@betabug.ch**20071117144917] =

[1348 - Quote the redirect URL for the "options" page.
betabug.darcs@betabug.ch**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.
betabug.darcs@betabug.ch**20071013183750] =

[1391 - fixed "Footer 'create' button without page name results in Attribut=
eError"
betabug.darcs@betabug.ch**20071105185015
 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 <simon@joyful.com>**20071104173259] =

[add a doc file overview to README
Simon Michael <simon@joyful.com>**20071104163944] =

[directory overview & more style notes
Simon Michael <simon@joyful.com>**20071104164649] =

[move/update some old style docs
Simon Michael <simon@joyful.com>**20071104154420] =

[start a developer style guide, with some documentation guidelines
Simon Michael <simon@joyful.com>**20071102174859] =

[clarify that handleEditText permissions check
Simon Michael <simon@joyful.com>**20071028080428] =

[a little whitespace
simon@joyful.com**20071028062937] =

[make linecounts
simon@joyful.com**20071028062925] =

[Recorded rating change.
betabug.darcs@betabug.ch**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.
betabug.darcs@betabug.ch**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.
betabug.darcs@betabug.ch**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.
betabug.darcs@betabug.ch**20071029174114] =

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

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

[move methods
Simon Michael <simon@joyful.com>**20071028014132] =

[comment cleanup
simon@joyful.com**20071028014019] =

[autoSubscriptionEnabled cleanup
Simon Michael <simon@joyful.com>**20071028011715] =

[append, edit cleanup
simon@joyful.com**20071028011427] =

[handleSubtopicsProperty cleanup
Simon Michael <simon@joyful.com>**20071028010818] =

[handleEditText cleanup
Simon Michael <simon@joyful.com>**20071028010617] =

[delete cleanup, drop unused updatebacklinks argument
Simon Michael <simon@joyful.com>**20071028010321] =

[handleRename cleanup
Simon Michael <simon@joyful.com>**20071028005220] =

[handleEditPageType cleanup
simon@joyful.com**20071028005122] =

[move a method
simon@joyful.com**20071028004655] =

[revert cleanup
simon@joyful.com**20071026162019] =

[setCreatorLike, setLastEditorLike
simon@joyful.com**20071026162005] =

[tests for new expunge methods
simon@joyful.com**20071026160319] =

[clarification
simon@joyful.com**20071026160308] =

[handy new manager methods expungeLastEditor, expungeLastEditorEverywhere; =
expunge, expungeEditsEverywhereBy cleanup
simon@joyful.com**20071026150936] =

[#1393 Catch ValueError too on importing unknown pagetypes.
betabug.darcs@betabug.ch**20071022074304] =

[PUT cleanup
Simon Michael <simon@joyful.com>**20071019053515] =

[file upload code cleanup
simon@joyful.com**20071018022343] =

[rename cleanup
simon@joyful.com**20071017125051] =

[cleanupText cleanup
simon@joyful.com**20071017123631] =

[clean up subtopicsEnabled
simon@joyful.com**20071016174006] =

[make bare page rendering at the debug prompt work again, cleanup
simon@joyful.com**20071016172335] =

[Catch only AttributeError for self.DestinationURL().
betabug.darcs@betabug.ch**20071013191137] =

[removed some unused code in ZWikiPage.py
Simon Michael <simon@joyful.com>**20071013190549] =

[os.mkdir will raise OSError, removed bare except.
betabug.darcs@betabug.ch**20071013184205] =

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

[notes update
simon@joyful.com**20071010163932] =

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

[Fix test_setupDtmlMethods for sitemap.xml.dtml.
betabug.darcs@betabug.ch**20071003183255] =

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

[wording
simon@joyful.com**20071010150624] =

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

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

[feedUrl
Simon Michael <simon@joyful.com>**20070924165908] =

[upgrade notes
Simon Michael <simon@joyful.com>**20070920192543] =

[more upgrade notes
Simon Michael <simon@joyful.com>**20070920190255] =

[clean up and add summary & upgrade notes for 0.60
simon@joyful.com**20070920185128] =

[convert recent relnote headings to definition lists like the rest
simon@joyful.com**20070920182235] =

[merge rc notes, add headings
simon@joyful.com**20070920181617] =

[mailin test comment
simon@joyful.com**20070919175328] =

[rename changes_rss to edits_rss (with a backwards compatibility alias) and
simon@joyful.com**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
simon@joyful.com**20070919060849] =

[fix darcs patch mailin test
simon@joyful.com**20070919055056] =

[test mailin of a darcs patch
simon@joyful.com**20070918164333] =

[1272 - create PageBrain only for Zwiki Pages.
betabug.darcs@betabug.ch**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
 method.
] =

[TAG release-0-60-0
simon@joyful.com**20070915222130] =

Patch bundle hash:
c42237a5effd65c9e8a2293b19994fba9a9f535e

--=_--

.

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

Looking at this thread http://www.gossamer-threads.com/lists/zope/dev/205917 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 http://archives.free.net.ph/message/20070204.032739.0ddbd6a9.en.html "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.