[Moin-devel] [PATCH] mapURL() should not choke on undefined URLs

Malte S. Stretz msquadrat.nospamplease at gmx.net
Sun Oct 17 08:02:02 EDT 2004


Moin,

I'm fiddling around with the 1.3 snapshot from yesterday and when I tried 
the url_mappings feature, Moin suddenly died witha rather long backtrace 
(see attachment).  It seems like the url parameter send to mapURL is for 
some reason undefined.  Dunno how that happens, I use the rightnavbar theme 
if that matters and it doesn't happen if I use the print view.

Whatever the reason is, mapURL() should not die on such a thing, patch 
attached.

Cheers,
Malte

-- 
[SGT] Simon G. Tatham: "How to Report Bugs Effectively"
      <http://www.chiark.greenend.org.uk/~sgtatham/bugs.html>
[ESR] Eric S. Raymond: "How To Ask Questions The Smart Way"
      <http://www.catb.org/~esr/faqs/smart-questions.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: moin-1.3-mapURL.patch
Type: text/x-diff
Size: 522 bytes
Desc: Patch against wikiutil.py
URL: <http://mail.python.org/pipermail/moin-devel/attachments/20041017/4b3f8c8f/attachment.patch>
-------------- next part --------------
AttributeError'NoneType' object has no attribute 'startswith'
Please include this information in your bug reports!:
Python Python 2.3.3: /usr/bin/python
Linux otherland 2.6.8-gentoo-r3 #2 Sun Sep 12 19:13:54 CEST 2004 i686
MoinMoin Release 1.3beta2 [Revision moin--main--1.3--patch-171]
Sun Oct 17 16:32:05 2004

A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.

 /home/mss/tmp/wikii/lib/python2.3/site-packages/MoinMoin/request.py in run(self=<MoinMoin.request.RequestCGI instance>)

  561             else:
  562                 try:
  563                     cgitb.Hook(file=self).handle(saved_exc)
  564                     # was: cgitb.handler()
  565                 except:

  
cgitb = <module 'MoinMoin.support.cgitb' from '/home/mss...hon2.3/site-packages/MoinMoin/support/cgitb.pyc'>, cgitb.Hook = <class MoinMoin.support.cgitb.Hook>, file undefined, self = <MoinMoin.request.RequestCGI instance>, ).handle undefined, saved_exc = (<class exceptions.AttributeError>, <exceptions.AttributeError instance>, <traceback object>)


 /home/mss/tmp/wikii/lib/python2.3/site-packages/MoinMoin/Page.py in send_page(self=<MoinMoin.Page.Page instance>, request=<MoinMoin.request.RequestCGI instance>, msg='', **keywords={'count_hit': 1})

  783         else:
  784             # parse the text and send the page content
  785             self.send_page_content(request, Parser, body, format_args=pi_formatargs, do_cache=do_cache)
  786 
  787             # check for pending footnotes
 

self = <MoinMoin.Page.Page instance>, self.send_page_content = <bound method Page.send_page_content of <MoinMoin.Page.Page instance>>, request = <MoinMoin.request.RequestCGI instance>, Parser = <class MoinMoin.parser.wiki.Parser>, body = u'= Describe AStA here. =\n\n * [http://asta.fh-wedel.de/ Website]\n * [wiki:AStA/Party Foo]\n\n', format_args undefined, pi_formatargs = '', do_cache = 1


 /home/mss/tmp/wikii/lib/python2.3/site-packages/MoinMoin/Page.py in send_page_content(self=<MoinMoin.Page.Page instance>, request=<MoinMoin.request.RequestCGI instance>, Parser=<class MoinMoin.parser.wiki.Parser>, body=u'= Describe AStA here. =\n\n * [http://asta.fh-wedel.de/ Website]\n * [wiki:AStA/Party Foo]\n\n', needsupdate=0, format_args='', do_cache=1)


  883             exec code
  884         except 'CacheNeedsUpdate': # if something goes wrong, try without caching
  885            self.send_page_content(request, Parser, body, needsupdate=1)
  886            cache = caching.CacheEntry(request, arena, key)
  887             
 

self = <MoinMoin.Page.Page instance>, self.send_page_content = <bound method Page.send_page_content of <MoinMoin.Page.Page instance>>, request = <MoinMoin.request.RequestCGI instance>, Parser = <class MoinMoin.parser.wiki.Parser>, body = u'= Describe AStA here. =\n\n * [http://asta.fh-wedel.de/ Website]\n * [wiki:AStA/Party Foo]\n\n', needsupdate = 0



 /home/mss/tmp/wikii/lib/python2.3/site-packages/MoinMoin/Page.py in send_page_content(self=<MoinMoin.Page.Page instance>, request=<MoinMoin.request.RequestCGI instance>, Parser=<class MoinMoin.parser.wiki.Parser>, body=u'= Describe AStA here. =\n\n * [http://asta.fh-wedel.de/ Website]\n * [wiki:AStA/Party Foo]\n\n', needsupdate=1, format_args='', do_cache=1)


  865             request.redirect(buffer)
  866             parser = Parser(body, request)
  867             parser.format(formatter)
  868             request.redirect()
  869             text = buffer.getvalue()
 

parser = <MoinMoin.parser.wiki.Parser instance>, parser.format = <bound method Parser.format of <MoinMoin.parser.wiki.Parser instance>>, formatter = <MoinMoin.formatter.text_python.Formatter instance>


 /home/mss/tmp/wikii/lib/python2.3/site-packages/MoinMoin/parser/wiki.py in format(self=<MoinMoin.parser.wiki.Parser instance>, formatter=<MoinMoin.formatter.text_python.Formatter instance>)


 1063                     self.in_table = 0
 1064             # convert line from wiki markup to HTML and print it
 1065             formatted_line = self.scan(scan_re, line)
 1066             
 1067             #self.request.write("<!-- %s\n     start -->\n" % line)
 

formatted_line = u'<<<>>>Describe AStA here.</h2>', self = <MoinMoin.parser.wiki.Parser instance>, self.scan = <bound method Parser.scan of <MoinMoin.parser.wiki.Parser instance>>, scan_re = <_sre.SRE_Pattern object>, line = u' * [http://asta.fh-wedel.de/ Website] '


 /home/mss/tmp/wikii/lib/python2.3/site-packages/MoinMoin/parser/wiki.py in scan(self=<MoinMoin.parser.wiki.Parser instance>, scan_re=<_sre.SRE_Pattern object>, line=u' * [http://asta.fh-wedel.de/ Website] ')


  877                     result.append(self.formatter.paragraph(1))
  878                 result.append(self.formatter.text(line[lastpos:match.start()]))
  879             result.append(self.replace(match))
  880 
  881             # search for the next one
 

result = ['<li>\n<p>\n', u' '], result.append = <built-in method append of list object>, self = <MoinMoin.parser.wiki.Parser instance>, self.replace = <bound method Parser.replace of <MoinMoin.parser.wiki.Parser instance>>, match = <_sre.SRE_Match object>


 /home/mss/tmp/wikii/lib/python2.3/site-packages/MoinMoin/parser/wiki.py in replace(self=<MoinMoin.parser.wiki.Parser instance>, match=<_sre.SRE_Match object>)


  903                             or (type in self.no_new_p_before)):
  904                         p = self.formatter.paragraph(1)
  905                     return p + getattr(self, '_' + type + '_repl')(hit) 
  906         else:
  907             import pprint
 

p = '', getattr undefined, self = <MoinMoin.parser.wiki.Parser instance>, type = u'url_bracket', hit = u'[http://asta.fh-wedel.de/ Website]'


 


 /home/mss/tmp/wikii/lib/python2.3/site-packages/MoinMoin/parser/wiki.py in _url_bracket_repl(self=<MoinMoin.parser.wiki.Parser instance>, word=u'[http://asta.fh-wedel.de/ Website]')


  454         else:
  455             return (self.formatter.url(1, words[0], 'external',
  456                                        type='www', unescaped=1) +
  457                     self.formatter.text(words[1]) +
  458                     self.formatter.url(0))
 

type undefined, unescaped undefined


 /home/mss/tmp/wikii/lib/python2.3/site-packages/MoinMoin/formatter/text_html.py in url(self=<MoinMoin.formatter.text_html.Formatter instance>, on=0, url=None, css=None, **kw={})


  130                 ... some more (!!! TODO) 
  131         """
  132         url = wikiutil.mapURL(self.request, url)
  133         pretty = kw.get('pretty_url', 0)
  134         title = kw.get('title', None)
 

url = None, global wikiutil = <module 'MoinMoin.wikiutil' from '/home/mss/tmp/...b/python2.3/site-packages/MoinMoin/wikiutil.pyc'>, wikiutil.mapURL = <function mapURL>, self = <MoinMoin.formatter.text_html.Formatter instance>, self.request = <MoinMoin.request.RequestCGI instance>


 


 /home/mss/tmp/wikii/lib/python2.3/site-packages/MoinMoin/wikiutil.py in mapURL(request=<MoinMoin.request.RequestCGI instance>, url=None)


  669         # check URL for the configured prefixes
  670         for prefix in request.cfg.url_mappings.keys():
  671             if url.startswith(prefix):
  672                 # substitute prefix with replacement value
  673                 return request.cfg.url_mappings[prefix] + url[len(prefix):]
 


url = None, url.startswith undefined, prefix = '/~mss/cgi-bin/moin.cgi'


AttributeError: 'NoneType' object has no attribute 'startswith' 
      __doc__ = 'Attribute not found.' 
      __getitem__ = <bound method AttributeError.__getitem__ of <exceptions.AttributeError instance>> 
      __init__ = <bound method AttributeError.__init__ of <exceptions.AttributeError instance>> 
      __module__ = 'exceptions' 
      __str__ = <bound method AttributeError.__str__ of <exceptions.AttributeError instance>> 
      args = ("'NoneType' object has no attribute 'startswith'",) 
      


More information about the Moin-devel mailing list