Ticket #3922 (closed defect: fixed)

Opened 5 years ago

Last modified 5 years ago

coercing to Unicode: need string or buffer, tuple found

Reported by: anonymous Assigned to: lcordier
Priority: normal Component: FreemindMacro
Severity: normal Keywords:
Cc: Trac Release: 0.11

Description

Hi,

I installed the FreeMindMacro?, however when I am trying to call a file embedded in a wiki page I get the following:

Error: Macro Freemind(wiki://WikiPageName/filename.mm?) failed

coercing to Unicode: need string or buffer, tuple found

Thanks!

Attachments

Change History

10/17/08 02:38:39 changed by anonymous

Ah I see between version 4500 and 4514 in SVN that you introduced the usage of the string_args unicode to string keys. I believe that might be giving me the problem. I don't know if it makes a difference or not but I'm on Python 2.4 on RHEL5.

diff U11i macro.py-rev4500.svn000.tmp.py macro.py-rev4514.svn000.tmp.py
--- macro.py-rev4500.svn000.tmp.py	Thu Oct 16 19:56:08 2008
+++ macro.py-rev4514.svn000.tmp.py	Thu Oct 16 19:56:12 2008
@@ -88,22 +88,23 @@
     
     return result
 
 
 class FreemindMacro(WikiMacroBase):
     
     implements(IWikiMacroProvider, ITemplateProvider)
     
     # IWikiMacroProvider methods
     def expand_macro(self, formatter, name, content):
         args, kwargs = parse_args(content, strict=False)
+        kwargs = string_keys(kwargs)
         
         if len(args) >= 1:
             url = args[0]
         elif len(args) == 0:
             raise TracError('URL to the mindmap at least required.')
         
         embed_count = getattr(formatter, EMBED_COUNT, 0)
         embed_count += 1
         setattr(formatter, EMBED_COUNT, embed_count)
         
         if embed_count == 1:
@@ -142,23 +143,22 @@
                 //fo.addVariable("unfoldAll","true");
                 fo.write("flashcontent%(count)02d");
             });
         ''' % {
             'count': embed_count,
             'visor': get_absolute_url(formatter.href.base, 'htdocs://freemind/swf/visorFreemind.swf'),
             'file': url,
             'base': base,
             'css': get_absolute_url(formatter.href.base, 'htdocs://freemind/css/flashfreemind.css'),
         }
         
-        kwargs = string_keys(kwargs)
         style_dict = xform_style(kwargs.get('style', ''))
         
         width = kwargs.pop('width', style_dict.get('width', '800px'))
         height = kwargs.pop('height', style_dict.get('height', '600px'))
         
         style_dict['border'] = style_dict.get('border', '1px solid #cccccc;')
         style_dict['margin'] = style_dict.get('margin', '0 auto')
         style_dict['width'] = width
         style_dict['height'] = height
         
         kwargs['style'] = xform_style(style_dict)

10/17/08 10:45:33 changed by anonymous

As you can see in the diff I only moved the position of kwargs = string_keys(kwargs). In [4520] I have updated that parsing to strict=True, this will only affect you if you had '=' signs in you url. I cannot replicate your error, but I added debug code to the sting_keys(kwargs) call. If the problem still persist, please paste the error output so that I have more information to go on.

From the ticket description you have Error: Macro Freemind(wiki://WikiPageName/filename.mm) failed am I correct in assuming that you have a wiki-page named WikiPageName? and you actually attached a file named filename.mm to that page ?

10/20/08 14:52:43 changed by anonymous

Thanks for the help so far. I do have the wiki page and the mind map names as above. Here is my debug log output after using your latest version of the macro.

2008-10-20 08:37:35,533 Trac[formatter] DEBUG: Executing Wiki macro Freemind by provider <freemind.macro.FreemindMacro object at 0xb79bd3ac> 2008-10-20 08:37:35,535 Trac[formatter] ERROR: Macro Freemind(wiki://GemsBmcUsage/filename.mm?) failed Traceback (most recent call last):

File "/usr/lib/python2.4/site-packages/Trac-0.11-py2.4.egg/trac/wiki/formatter.py", line 468, in _macro_formatter

return macro.process(args, in_paragraph=True)

File "/usr/lib/python2.4/site-packages/Trac-0.11-py2.4.egg/trac/wiki/formatter.py", line 179, in process

text = self.processor(text)

File "/usr/lib/python2.4/site-packages/Trac-0.11-py2.4.egg/trac/wiki/formatter.py", line 166, in _macro_processor

text)

File "build/bdist.linux-i686/egg/freemind/macro.py", line 132, in expand_macro File "build/bdist.linux-i686/egg/freemind/macro.py", line 48, in get_absolute_url

TypeError?: coercing to Unicode: need string or buffer, tuple found 2008-10-20 08:37:35,594 Trac[main] DEBUG: 734 unreachable objects found.

10/20/08 16:08:09 changed by lcordier

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

(In [4544]) Fix #3922 and incorporate #3938.


Add/Change #3922 (coercing to Unicode: need string or buffer, tuple found)




Change Properties
Action