#7188 closed defect (worksforme)
wiki_to_oneliner throws AttributeError: 'NoneType' object has no attribute 'ticket'
| Reported by: | Owned by: | Christian Boos | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | wiki system | Version: | 0.11-stable | 
| Severity: | normal | Keywords: | |
| Cc: | Branch: | ||
| Release Notes: | |||
| API Changes: | |||
| Internal Changes: | |||
Description
How to Reproduce
call wiki_to_oneliner with a ticket number in it. For example, "ticket #1 ticket". I tried using Formatter and it works. I couldn't figure out how to "upgrade" my code to use format_to_oneliner
User Agent was: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13
System Information
| Trac |  0.11dev-r6941 
 | 
| Python |  2.4.3 (#2, Oct  6 2006, 07:52:30)  [GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] 
 | 
| setuptools |  0.6c7 
 | 
| SQLite |  3.2.8 
 | 
| pysqlite |  2.0.5 
 | 
| Genshi |  0.5dev-r847 
 | 
| Pygments |  0.9 
 | 
| Subversion |  1.3.1 (r19032) 
 | 
| jQuery: |  1.2.3 
 | 
Python Traceback
Traceback (most recent call last):
  File "/home/jpwasp/trac/0.11/trac-0.11/trac/web/main.py", line 417, in _dispatch_request
    dispatcher.dispatch(req)
  File "/home/jpwasp/trac/0.11/trac-0.11/trac/web/main.py", line 219, in dispatch
    data, content_type)
  File "/home/jpwasp/trac/0.11/trac-0.11/trac/web/chrome.py", line 726, in render_template
    stream.render(method, doctype=doctype, out=buffer)
  File "build/bdist.linux-i686/egg/genshi/core.py", line 179, in render
  File "build/bdist.linux-i686/egg/genshi/output.py", line 61, in encode
  File "build/bdist.linux-i686/egg/genshi/output.py", line 302, in __call__
  File "build/bdist.linux-i686/egg/genshi/output.py", line 727, in __call__
  File "build/bdist.linux-i686/egg/genshi/output.py", line 566, in __call__
  File "build/bdist.linux-i686/egg/genshi/output.py", line 672, in __call__
  File "build/bdist.linux-i686/egg/genshi/output.py", line 506, in __call__
  File "build/bdist.linux-i686/egg/genshi/core.py", line 280, in _ensure
  File "build/bdist.linux-i686/egg/genshi/core.py", line 280, in _ensure
  File "/home/jpwasp/trac/0.11/trac-0.11/trac/web/chrome.py", line 779, in _strip_accesskeys
    for kind, data, pos in stream:
  File "build/bdist.linux-i686/egg/genshi/core.py", line 280, in _ensure
  File "/home/jpwasp/trac/0.11/trac-0.11/trac/web/chrome.py", line 768, in _generate
    for kind, data, pos in stream:
  File "build/bdist.linux-i686/egg/genshi/core.py", line 280, in _ensure
  File "build/bdist.linux-i686/egg/genshi/template/base.py", line 565, in _include
  File "build/bdist.linux-i686/egg/genshi/template/markup.py", line 299, in _match
  File "build/bdist.linux-i686/egg/genshi/template/markup.py", line 299, in _match
  File "build/bdist.linux-i686/egg/genshi/template/markup.py", line 278, in _match
  File "build/bdist.linux-i686/egg/genshi/template/base.py", line 565, in _include
  File "build/bdist.linux-i686/egg/genshi/template/markup.py", line 246, in _match
  File "build/bdist.linux-i686/egg/genshi/template/markup.py", line 235, in _strip
  File "build/bdist.linux-i686/egg/genshi/template/base.py", line 539, in _exec
  File "build/bdist.linux-i686/egg/genshi/template/base.py", line 529, in _eval
  File "build/bdist.linux-i686/egg/genshi/template/base.py", line 492, in _eval
  File "build/bdist.linux-i686/egg/genshi/template/base.py", line 547, in _flatten
  File "build/bdist.linux-i686/egg/genshi/core.py", line 280, in _ensure
  File "build/bdist.linux-i686/egg/genshi/path.py", line 141, in _generate
  File "build/bdist.linux-i686/egg/genshi/template/base.py", line 565, in _include
  File "build/bdist.linux-i686/egg/genshi/template/markup.py", line 235, in _strip
  File "build/bdist.linux-i686/egg/genshi/template/base.py", line 539, in _exec
  File "build/bdist.linux-i686/egg/genshi/template/base.py", line 529, in _eval
  File "build/bdist.linux-i686/egg/genshi/template/base.py", line 492, in _eval
  File "build/bdist.linux-i686/egg/genshi/template/base.py", line 547, in _flatten
  File "build/bdist.linux-i686/egg/genshi/core.py", line 280, in _ensure
  File "build/bdist.linux-i686/egg/genshi/path.py", line 141, in _generate
  File "build/bdist.linux-i686/egg/genshi/template/base.py", line 565, in _include
  File "build/bdist.linux-i686/egg/genshi/template/markup.py", line 235, in _strip
  File "build/bdist.linux-i686/egg/genshi/template/base.py", line 539, in _exec
  File "build/bdist.linux-i686/egg/genshi/template/base.py", line 516, in _eval
  File "build/bdist.linux-i686/egg/genshi/template/base.py", line 282, in _eval_expr
  File "build/bdist.linux-i686/egg/genshi/template/eval.py", line 158, in evaluate
  File "/home/jpwasp/trac/0.11/trac-0.11/trac/wiki/templates/wiki_edit.html", line 56, in <Expression u'wiki_to_html(context(page.resource), page.text)'>
    ${wiki_to_html(context(page.resource), page.text)}
  File "/home/jpwasp/trac/0.11/trac-0.11/trac/util/compat.py", line 130, in newfunc
    return func_(*(args + fargs), **dict(kwargs, **fkwargs))
  File "/home/jpwasp/trac/0.11/trac-0.11/trac/wiki/formatter.py", line 1094, in format_to_html
    return HtmlFormatter(env, context, wikidom).generate(escape_newlines)
  File "/home/jpwasp/trac/0.11/trac-0.11/trac/wiki/formatter.py", line 1053, in generate
    escape_newlines)
  File "/home/jpwasp/trac/0.11/trac-0.11/trac/wiki/formatter.py", line 833, in format
    self.handle_code_block(line)
  File "/home/jpwasp/trac/0.11/trac-0.11/trac/wiki/formatter.py", line 764, in handle_code_block
    processed = self.code_processor.process(code_text)
  File "/home/jpwasp/trac/0.11/trac-0.11/trac/wiki/formatter.py", line 179, in process
    text = self.processor(text)
  File "/home/jpwasp/trac/0.11/trac-0.11/trac/wiki/formatter.py", line 166, in _macro_processor
    text)
  File "/home/jpwasp/trac/0.11/trac-0.11/trac/wiki/macros.py", line 66, in expand_macro
    return self.render_macro(formatter.req, name, content)
  File "/home/jpwasp/trac/0.11/testenv/plugins/SmartTable.py", line 66, in render_macro
    out.write(rowTemplate % wiki_to_oneliner(col, self.env))
  File "/home/jpwasp/trac/0.11/trac-0.11/trac/wiki/formatter.py", line 1126, in wiki_to_oneliner
    OneLinerFormatter(env, context).format(wikitext, out, shorten)
  File "/home/jpwasp/trac/0.11/trac-0.11/trac/wiki/formatter.py", line 953, in format
    result = re.sub(self.wikiparser.rules, self.replace, result)
  File "/usr/lib/python2.4/sre.py", line 142, in sub
    return _compile(pattern, 0).sub(repl, string, count)
  File "/home/jpwasp/trac/0.11/trac-0.11/trac/wiki/formatter.py", line 807, in replace
    replacement = self.handle_match(fullmatch)
  File "/home/jpwasp/trac/0.11/trac-0.11/trac/wiki/formatter.py", line 800, in handle_match
    return external_handler(self, match, fullmatch)
  File "/home/jpwasp/trac/0.11/trac-0.11/trac/ticket/api.py", line 302, in <lambda>
    lambda x, y, z: self._format_link(x, 'ticket', y[1:], y, z))
  File "/home/jpwasp/trac/0.11/trac-0.11/trac/ticket/api.py", line 325, in _format_link
    href = formatter.href.ticket(num) + params + fragment
AttributeError: 'NoneType' object has no attribute 'ticket'
      Attachments (0)
Change History (3)
comment:1 by , 18 years ago
| Component: | general → wiki system | 
|---|---|
| Owner: | changed from to | 
comment:2 by , 18 years ago
| Milestone: | 0.11 | 
|---|---|
| Resolution: | → worksforme | 
| Status: | new → closed | 
  File "/home/jpwasp/trac/0.11/testenv/plugins/SmartTable.py", line 66, in render_macro
    out.write(rowTemplate % wiki_to_oneliner(col, self.env))
Should be:
out.write(rowTemplate % wiki_to_oneliner(col, self.env, req=req)
or even better, use the 0.11 API:
def expand_macro(self, formatter, name, content): # render_macro has been deprecated in 0.11 ... out.write(rowTemplate % format_to_oneliner(self.env, formatter.context, col))
comment:3 by , 18 years ago
Thanks for the help. I guess this wasn't a Trac bug; I thought it was because it worked in 0.10. I'm having a real hard time trying to do stuff with Python and Trac, mostly because I don't understand how to develop with it yet. For example I've yet to figure out where to go to find out methods and variables. Formatter is an object, but I only know that from your example. And I only know about self.env from examples as well.
I know that the ticket system isn't the place for this, so I've moved my call to help to the trac-users list. I think once I figure out how to find out what parameters a function takes, what types I am getting and a list of methods, etc, I would be in much better shape. Right now I can't tell an integer from an object so my development method is "guess and test." I'm sure I'm missing some basic Python technique.



  
Forgot to properly categorize this