Modify

Ticket #296 (closed defect: fixed)

Opened 5 years ago

Last modified 5 years ago

'unicode' object has no attribute 'partition'

Reported by: hkunz@… Owned by: moschny
Priority: normal Milestone:
Component: trac.tracnav Version: tracnav-devel
Severity: normal Keywords:
Cc: christian@…

Description

Hi,

I upgraded from trac 0.10 to 0.11.1 Upgrading TracNav to 4.1 didn't work. I get

Error: Macro TracNav(TracNav/Main) failed

'unicode' object has no attribute 'partition'

thanks for any hints resolving this.

cheers, Hanspeter

Attachments

Change History

comment:1 Changed 5 years ago by christian@…

I see the same issue. My setup is as follows:

  • Fedora Core 4 on Amazon EC2
  • Python 2.4
  • Trac 0.11.1
  • PostgreSQL 8.2
  • Psycopg2
  • TracNac installed via easy_install (version 4.1)

Every page with TracNav shows a:

Error: Macro TracNav(Manual/Toc) failed

'unicode' object has no attribute 'partition'

comment:2 Changed 5 years ago by christian@…

  • Cc christian@… added

A little further research has revealed that this is a python 2.4 issue with TracNav. Line 129 of tracnav.py:

 for arg, _, values in map(lambda s: s.partition('='), args.split('|')):

The partition method is added to the string class as of Python 2.5 (as shown here: http://bytes.com/forum/thread537988.html among other places).

I guess Python 2.5 should be listed as a requirement or the above line should be rewritten to work without the partition method.

comment:3 Changed 5 years ago by christian@…

Update:

Being a little desperate I decided to hack this to work. I followed the steps below to make TracNav work with my Python 2.4 setup.

  • Get the source from SVN
  • Edit tracnav.py from line 129 - my file looks like this after edit
                #Commented out to ignore Python 2.4 issues
                #Using hardcoded config instead
                self.collapse = True
                self.modify = True
                self.reorder = True
    
                #for arg, _, values in map(lambda s: s.partition('='), args.split('|')):
                #    arg = arg.strip()
                #    if arg == 'nocollapse':
                #        self.collapse = False
                #    elif arg == 'noedit':
                #        self.modify = False
                #    elif arg == 'noreorder':
                #        self.reorder = False
                #    elif arg == 'allowed_macros':
                #        self.allowed_macros = map(lambda s: s.strip(), values.split(','))
                #    else:
                #        self.names.append(arg)
    
    
  • Remove any old installs of TracNav
  • Build and install the modified version

Note: This approach has the following drawbacks:

  • No configuration possible from Trac
  • You TOC MUST be at /wiki/TOC (this can possibly also be hardcoded..)
  • Possibly others - I intent to use this only untill a fix is released or I upgrade to python 2.5

comment:4 Changed 5 years ago by moschny

  • Status changed from new to assigned

Hi guys, sorry for breaking backwards compatibility with Python 2.4.

Committed a fix in [3273], please test. You should be able to use

easy_install TracNav==dev

to install the development version.

comment:5 Changed 5 years ago by hkunz@…

  • Status changed from assigned to closed
  • Resolution set to fixed

Installed the newest development version - worked! excellent. Many thanks, Hp.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


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

 
Note: See TracTickets for help on using tickets.