# HG changeset patch # User Alexander Schremmer # Date 1153567536 -7200 # Node ID 4725c8ac809af92b326fc79903b4fe4bc73cf24c # Parent 0f7f98a19685e4d21b80c54751c64ef1c138c8d3 Fixed Python 2.5 incompatibility issues (avoid str exceptions), made the bytecode more resistant for people using data directoriees with different MoinMoin versions. diff -r 0f7f98a19685 -r 4725c8ac809a MoinMoin/Page.py --- a/MoinMoin/Page.py Sat Jul 22 13:24:39 2006 +0200 +++ b/MoinMoin/Page.py Sat Jul 22 13:25:36 2006 +0200 @@ -1036,7 +1036,7 @@ except wikiutil.PluginMissingError: pass else: - raise "Plugin missing error!" # XXX what now? + raise NotImplementedError("Plugin missing error!") # XXX what now? request.formatter = self.formatter self.formatter.setPage(self) if self.hilite_re: @@ -1247,7 +1247,7 @@ except wikiutil.PluginMissingError: pass else: - raise "No matching parser" # XXX what do we use if nothing at all matches? + raise NotImplementedError("No matching parser") # XXX what do we use if nothing at all matches? # start wiki content div request.write(self.formatter.startContent(content_id)) @@ -1339,7 +1339,7 @@ except wikiutil.PluginMissingError: pass else: - raise "no matching parser" # XXX what now? + raise NotImplementedError("no matching parser") # XXX what now? return getattr(parser, 'caching', False) return False @@ -1362,11 +1362,15 @@ try: code = self.loadCache(request) self.execute(request, parser, code) - except 'CacheNeedsUpdate': + except Exception, (msg, ): + if msg != 'CacheNeedsUpdate': + raise try: code = self.makeCache(request, parser) self.execute(request, parser, code) - except 'CacheNeedsUpdate': + except Exception, (msg, ): + if msg != 'CacheNeedsUpdate': + raise request.log('page cache failed after creation') self.format(parser) @@ -1392,19 +1396,21 @@ cache = caching.CacheEntry(request, self, self.getFormatterName(), scope='item') attachmentsPath = self.getPagePath('attachments', check_create=0) if cache.needsUpdate(self._text_filename(), attachmentsPath): - raise 'CacheNeedsUpdate' + raise Exception('CacheNeedsUpdate') import marshal try: return marshal.loads(cache.content()) + except "CacheNeedsUpdate": # convert old exception into a new one + raise Exception('CacheNeedsUpdate') except (EOFError, ValueError, TypeError): # Bad marshal data, must update the cache. # See http://docs.python.org/lib/module-marshal.html - raise 'CacheNeedsUpdate' + raise Exception('CacheNeedsUpdate') except Exception, err: request.log('fail to load "%s" cache: %s' % (self.page_name, str(err))) - raise 'CacheNeedsUpdate' + raise Exception('CacheNeedsUpdate') def makeCache(self, request, parser): """ Format content into code, update cache and return code """ diff -r 0f7f98a19685 -r 4725c8ac809a MoinMoin/formatter/text_python.py --- a/MoinMoin/formatter/text_python.py Sat Jul 22 13:24:39 2006 +0200 +++ b/MoinMoin/formatter/text_python.py Sat Jul 22 13:25:36 2006 +0200 @@ -54,8 +54,9 @@ waspcode_timestamp = int(time.time()) source = [""" moincode_timestamp = int(os.path.getmtime(os.path.dirname(__file__))) -if moincode_timestamp > %d or request.cfg.cfg_mtime > %d: - raise "CacheNeedsUpdate" +cfg_mtime = getattr(request.cfg, "cfg_mtime", None) +if moincode_timestamp > %d or cfg_mtime is None or cfg_mtime > %d: + raise Exception("CacheNeedsUpdate") """ % (waspcode_timestamp, waspcode_timestamp)]