Ticket #10790 (closed defect: fixed)

Opened 4 months ago

Last modified 4 months ago

ImportError preventing plugin from being loaded

Reported by: mike.charles@noaa.gov Assigned to: matobaa
Priority: normal Component: TracLinksPlugin
Severity: blocker Keywords: ImportError
Cc: matobaa 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

Change History

01/11/13 18:20:01 changed by matobaa

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.

01/11/13 18:25:09 changed by anonymous

  • status changed from new to assigned.

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!

01/11/13 18:38:04 changed by matobaa

  • cc set to matobaa.

01/11/13 18:41:18 changed by jun66j5

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.

Index: traclinks/textbox.py
===================================================================
--- traclinks/textbox.py        (revision 12516)
+++ traclinks/textbox.py        (working copy)
@@ -10,7 +10,7 @@
 from trac.web.api import ITemplateStreamFilter
 from trac.web.chrome import ITemplateProvider, add_script
 from trac.wiki.api import IWikiSyntaxProvider
-from trac.util.text import quote_query_string
+from trac.util.text import unicode_urlencode

 class TextBox(Component):
     """ Generate TracLinks in search box for:
@@ -104,9 +104,10 @@
             traclinks = '%s:%s' % (resource.realm, traclinks)
             # new ticket template
             if resource.id == None and resource.realm == 'ticket':
-                v = data['ticket'].values
-                keyvalue = ['%s=%s' % (k, quote_query_string(v[k])) for k in v.keys() if v[k] not in (None, '')]
-                traclinks = '[/newticket?%s]' % '&'.join(keyvalue)
+                query_string = unicode_urlencode(
+                    [(k, v) for k, v in data['ticket'].values.iteritems()
+                            if v not in (None, '')])
+                traclinks = '[/newticket?%s]' % query_string
             return stream | Transformer('//input[@id="proj-search"]').attr('value', traclinks).attr('size', '50')
         return stream

01/18/13 22:19:34 changed 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?

01/23/13 06:01:09 changed by matobaa

  • status changed from assigned to closed.
  • resolution set to fixed.

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

01/23/13 06:01:56 changed by matobaa

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


Add/Change #10790 (ImportError preventing plugin from being loaded)




Change Properties
Action