Modify

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#10790 closed defect (fixed)

ImportError preventing plugin from being loaded

Reported by: mike.charles@… Owned by: Matoba Akihiro
Priority: normal Component: TracLinksPlugin
Severity: blocker Keywords: ImportError
Cc: Matoba Akihiro Trac Release: 0.12

Description

I had been using the TracLinksPlugin on Trac 0.12.2 for a while, and recently migrated Trac to a new server with the same version of Python, but now using Trac 0.12.4.

The TracLinksPlugin no longer works. It tries to load, but I get the following in trac.log:

2013-01-11 16:03:02,896 Trac[loader] DEBUG: Loading TracLinks from /cpc/devtools/trac/plugins/eggs/TracLinks-0.4-py2.4.egg
2013-01-11 16:03:02,896 Trac[loader] ERROR: Skipping "TracLinks = traclinks.textbox": (can't import "ImportError: cannot import name quote_query_string")

Do you know why this might happen?

Attachments (0)

Change History (7)

comment:1 Changed 4 years ago by Matoba Akihiro

I don't know why ... trac 0.12.4 has the method: http://trac.edgewall.org/browser/tags/trac-0.12.4/trac/util/text.py#L178

In my PC, TracLinksPlugin works well with trac-0.12.3 + Python 2.7.3.

The import was added on changeset:12082.
If you don't need "new ticket template" and "hash link" feature,
please use source:/trunk/traclinksplugin/0.12@11593 of this plugin
or reverse patch changeset:12082 to avoid the error.

comment:2 Changed 4 years ago by anonymous

Status: newassigned

Ok, I thought of one possible reason, our Trac installation is an egg file, instead of being an unzipped egg. I asked our IT team to unzip the Trac egg installation. Once they've done that I'll try the plugin again. If that doesn't work, I'll try your suggestion.

Thanks for the fast reply!

comment:3 Changed 4 years ago by Matoba Akihiro

Cc: Matoba Akihiro added; anonymous removed

comment:4 Changed 4 years ago by Jun Omae

quote_query_string is available in Trac 0.12.4, however it is unavailable in 0.12.3. We should use unicode_urlencode which is available in Trac 0.10 instead.

  • traclinks/textbox.py

     
    1010from trac.web.api import ITemplateStreamFilter
    1111from trac.web.chrome import ITemplateProvider, add_script
    1212from trac.wiki.api import IWikiSyntaxProvider
    13 from trac.util.text import quote_query_string
     13from trac.util.text import unicode_urlencode
    1414
    1515class TextBox(Component):
    1616    """ Generate TracLinks in search box for:
     
    104104            traclinks = '%s:%s' % (resource.realm, traclinks)
    105105            # new ticket template
    106106            if resource.id == None and resource.realm == 'ticket':
    107                 v = data['ticket'].values
    108                 keyvalue = ['%s=%s' % (k, quote_query_string(v[k])) for k in v.keys() if v[k] not in (None, '')]
    109                 traclinks = '[/newticket?%s]' % '&'.join(keyvalue)
     107                query_string = unicode_urlencode(
     108                    [(k, v) for k, v in data['ticket'].values.iteritems()
     109                            if v not in (None, '')])
     110                traclinks = '[/newticket?%s]' % query_string
    110111            return stream | Transformer('//input[@id="proj-search"]').attr('value', traclinks).attr('size', '50')
    111112        return stream
    112113

comment:5 Changed 4 years ago by anonymous

Ok, my thoughts in comment:2 were correct, once I unzipped the Python egg that Trac was installed as, it worked fine.

Do you want to keep this ticket open for comment:4?

comment:6 Changed 4 years ago by Matoba Akihiro

Resolution: fixed
Status: assignedclosed

(In [12561]) TracLinksPlugin: fix a bug in new ticket preview, closes #10790 (worksforme), applied patch in comment:4:ticket:10790.

comment:7 Changed 4 years ago by Matoba Akihiro

(In [12562]) TracLinksPlugin: fix a bug in new ticket preview, closes #10790 (worksforme), applied patch in comment:4:ticket:10790.

Modify Ticket

Action
as closed The owner will remain Matoba Akihiro.
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.