Modify

Opened 16 years ago

Closed 16 years ago

#3485 closed defect (fixed)

FullBlogPlugin does not work on python 2.3

Reported by: yamasaki Owned by: osimons
Priority: normal Component: FullBlogPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.11

Description


Oops… Trac detected an internal error: NameError: global name 'sorted' is not defined If you think this should work you can reproduce the problem, you should consider reporting this to the Trac team.

Before you do that, though, please first try searching for similar issues, as it is quite likely that this problem has been reported before. For questions about installation and configuration of Trac, please try the mailing list instead of filing a ticket.

Otherwise, please

How to Reproduce

While doing a GET operation on /blog, Trac issued an internal error.

(please provide additional details here)

Request parameters:

{'blog_path': ''}

User Agent was: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)

System Information

Trac 0.11
Python 2.3.5 (#1, May 5 2005, 10:58:47)
[GCC 3.3.5 (Debian 1:3.3.5-12)]
setuptools 0.6c8
SQLite 2.8.16
pysqlite 1.0.1
Genshi 0.5.1
mod_python < 3.2
Subversion 1.1.4 (r13838)
jQuery: 1.2.3

Python Traceback

Traceback (most recent call last):
  File "/usr/lib/python2.3/site-packages/Trac-0.11-py2.3.egg/trac/web/main.py", line 423, in _dispatch_request
    dispatcher.dispatch(req)
  File "/usr/lib/python2.3/site-packages/Trac-0.11-py2.3.egg/trac/web/main.py", line 197, in dispatch
    resp = chosen_handler.process_request(req)
  File "/usr/lib/python2.3/site-packages/TracFullBlogPlugin-0.1-py2.3.egg/tracfullblog/web_ui.py", line 352, in process_request
    data['blog_months'], data['blog_authors'], data['blog_categories'], \
  File "/usr/lib/python2.3/site-packages/TracFullBlogPlugin-0.1-py2.3.egg/tracfullblog/core.py", line 315, in get_months_authors_categories
    return ([(m, m_dict.get(m, 0)) for m in sorted(m_dict.keys(), reverse=True)],
NameError: global name 'sorted' is not defined

a new ticket at the Trac project site, where you can describe the problem and explain how to reproduce it.

Python Traceback Most recent call last: File "/usr/lib/python2.3/site-packages/Trac-0.11-py2.3.egg/trac/web/main.py", line 423, in _dispatch_request Code fragment:

try: if not env and env_error: raise HTTPInternalError(env_error) try: dispatcher = RequestDispatcher(env)

dispatcher.dispatch(req)

except RequestDone: pass resp = req._response or [] except HTTPException, e:

Local variables:

Name Value after [u' except RequestDone:', u' pass', u' resp = ... before [u' try:', u' if not env and env_error:', u' raise ... dispatcher <trac.web.main.RequestDispatcher object at 0x2aaaafa44810> e <exceptions.NameError instance at 0x2aaab0a6f290> env <trac.env.Environment object at 0x2aaaaea9f210> env_error None exc_info (<class exceptions.NameError at 0x2aaaad3b45f0>, <exceptions.NameError ... filename '/usr/lib/python2.3/site-packages/Trac-0.11-py2.3.egg/trac/web/main.py' frames [{'function': '_dispatch_request', 'lines_before': [u' try:', u' ... has_admin True line u' dispatcher.dispatch(req)' lineno 422 message u"NameError: global name 'sorted' is not defined" req <Request "GET u'/blog'"> resp [] tb <traceback object at 0x2aaab0a6f368> tb_hide None traceback 'Traceback (most recent call last):\n File ...

File "/usr/lib/python2.3/site-packages/Trac-0.11-py2.3.egg/trac/web/main.py", line 197, in dispatch Code fragment:

req.args.get('FORM_TOKEN') != req.form_token: raise HTTPBadRequest('Missing or invalid form token. ' 'Do you have cookies enabled?') # Process the request and render the template

resp = chosen_handler.process_request(req) if resp: if len(resp) == 2: # Clearsilver chrome.populate_hdf(req) template, content_type = \ self._post_process_request(req, *resp)

Local variables:

Name Value chosen_handler <tracfullblog.web_ui.FullBlogModule object at 0x2aaaafa44d10> chrome <trac.web.chrome.Chrome object at 0x2aaaaf4db7d0> err (<class exceptions.NameError at 0x2aaaad3b45f0>, <exceptions.NameError ... handler <tracfullblog.web_ui.FullBlogModule object at 0x2aaaafa44d10> req <Request "GET u'/blog'"> self <trac.web.main.RequestDispatcher object at 0x2aaaafa44810>

File "/usr/lib/python2.3/site-packages/TracFullBlogPlugin-0.1-py2.3.egg/tracfullblog/web_ui.py", line 352, in process_request Code fragment:

if (not command or command.startswith('listing-')) and format == 'rss': datacontext? = Context.from_request(req, absurls=True) return 'fullblog.rss', data, 'application/rss+xml'

datablog_months?, datablog_authors?, datablog_categories?, \

datablog_total? = \ blog_core.get_months_authors_categories( user=req.authname, perm=req.perm) if 'BLOG_CREATE' in req.perm('blog'): add_ctxtnav(req, 'New Post', href=req.href.blog('create'),

Local variables:

Name Value action 'view' blog_core <tracfullblog.core.FullBlogCore object at 0x2aaaafa46090> blog_month_names [u'January', u'February', u'March', u'April', u'May', u'June', u'July', ... blog_posts [] command count 0 data {'blog_month_names': [u'January', u'February', u'March', u'April', u'May', ... format listing_data {} maxcount 20 pagename path_items [] req <Request "GET u'/blog'"> self <tracfullblog.web_ui.FullBlogModule object at 0x2aaaafa44d10> template 'fullblog_view.html' version 0

File "/usr/lib/python2.3/site-packages/TracFullBlogPlugin-0.1-py2.3.egg/tracfullblog/core.py", line 315, in get_months_authors_categories Code fragment:

a_dict[author] = a_dict.get(author, 0) + 1 categories = post[6] # a list for category in set(categories): c_dict[category] = c_dict.get(category, 0) + 1 total += 1

return ([(m, m_dict.get(m, 0)) for m in sorted(m_dict.keys(), reverse=True)],

[(a, a_dict.get(a, 0)) for a in sorted(a_dict.keys())], [(c, c_dict.get(c, 0)) for c in sorted(c_dict.keys())], total) # Internal methods

Local variables:

Name Value _[1] <built-in method append of list object at 0x2aaab03515d0> a_dict {} blog_posts [] c_dict {} from_dt None m_dict {} perm <trac.perm.PermissionCache object at 0x2aaab0adbbe0> self <tracfullblog.core.FullBlogCore object at 0x2aaaafa46090> to_dt None total 0 user u'yamasaki'

File "/usr/lib/python2.3/site-packages/Trac-0.11-py2.3.egg/trac/web/main.py", line 423, in _dispatch_request

dispatcher.dispatch(req)

File "/usr/lib/python2.3/site-packages/Trac-0.11-py2.3.egg/trac/web/main.py", line 197, in dispatch

resp = chosen_handler.process_request(req)

File "/usr/lib/python2.3/site-packages/TracFullBlogPlugin-0.1-py2.3.egg/tracfullblog/web_ui.py", line 352, in process_request

datablog_months?, datablog_authors?, datablog_categories?, \

File "/usr/lib/python2.3/site-packages/TracFullBlogPlugin-0.1-py2.3.egg/tracfullblog/core.py", line 315, in get_months_authors_categories

return ([(m, m_dict.get(m, 0)) for m in sorted(m_dict.keys(), reverse=True)],

System Information: User Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)

Trac: 0.11 Python: 2.3.5 (#1, May 5 2005, 10:58:47) [GCC 3.3.5 (Debian 1:3.3.5-12)] setuptools: 0.6c8 SQLite: 2.8.16 pysqlite: 1.0.1 Genshi: 0.5.1 mod_python: < 3.2 Subversion: 1.1.4 (r13838) jQuery: 1.2.3

Attachments (0)

Change History (4)

comment:1 Changed 16 years ago by Alec Thomas

Component: TracHacksFullBlogPlugin
Owner: changed from Alec Thomas to osimons

You created this against TracHacks, please specify the right component when creating bugs or the owner will never see them.

Also, this bug is triggered because the plugin is using Python 2.4 specific constructs and you're running Python 2.3.

comment:2 Changed 16 years ago by osimons

Trac Release: 0.100.11

Near the top of the tracfullblog/core.py file, could you add this import:

from trac.util.compat import sorted

Does everything work now?

comment:3 Changed 16 years ago by yamasaki

(1) athomas: I am sorry for my mistake, and thank you for your correction.

(2) osmions: Thank you very much for your patch. I have tried the pache, and the first screen was displayed normally. But posting entry does not work.

NameError: global name 'set' is not defined

So I add the following line and post/read/comment/attach/tag works fine.

from trac.util.compat import set

Thank you very much! --yamasaki

comment:4 Changed 16 years ago by osimons

Resolution: fixed
Status: newclosed

(In [4102]) FullBlogPlugin: Python 2.3 compat fix.

Closes #3485.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain osimons.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.