Ticket #6258 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

'Fragment' object has no attribute 'attrib'

Reported by: sebastian.paniagua@gmail.com Assigned to: rudyryk
Priority: normal Component: FlashEmbedMacro
Severity: normal Keywords:
Cc: Trac Release: 0.11

Description

This error was shown when i tried to embed a .swf movie

Error: Macro Embed(swf=attachment:output.swf,w=400,h=300) failed
'Fragment' object has no attribute 'attrib'

Attachments

Change History

11/27/09 14:49:22 changed by sebastian.paniagua@gmail.com

I'm using Trac 0.11.1, Python 2.5.2

This is the log:

2009-11-27 11:36:49,548 Trac[formatter] ERROR: Macro Embed(swf=attachment:test2.swf,w=400,h=300) failed:
Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/trac/wiki/formatter.py", line 480, in _macro_formatter
    return macro.process(args, in_paragraph=True)
  File "/usr/lib/python2.5/site-packages/trac/wiki/formatter.py", line 180, in process
    text = self.processor(text)
  File "/usr/lib/python2.5/site-packages/trac/wiki/formatter.py", line 167, in _macro_processor
    text)
  File "/usr/lib/python2.5/site-packages/TracFlashEmbedMacro-0.95RC1-py2.5.egg/tracflashembed/macros.py", line 55, in expand_macro
    return embed_swf(formatter, params)
  File "/usr/lib/python2.5/site-packages/TracFlashEmbedMacro-0.95RC1-py2.5.egg/tracflashembed/macros.py", line 101, in embed_swf
    url = '/raw-' + url.attrib.get('href')[1:]
AttributeError: 'Fragment' object has no attribute 'attrib'

03/23/10 09:23:07 changed by rjollos

I'm also seeing this issue with Trac 0.11.7

(follow-up: ↓ 4 ) 03/24/10 21:09:59 changed by mkc

The extract_link code now returns a stream instead of one element. The following diff should fix for inputs following forms: [[Embed(swf=output.swf)]] [[Embed(swf=attachment:output.swf)]]

Index: tracflashembed/macros.py
===================================================================
--- tracflashembed/macros.py	(revision 7791)
+++ tracflashembed/macros.py	(working copy)
@@ -9,7 +9,6 @@
 from StringIO import StringIO
 from genshi.builder import tag
 from trac.wiki.api import IWikiMacroProvider, parse_args
-from trac.wiki.formatter import format_to_oneliner, extract_link
 from trac.wiki.macros import WikiMacroBase
 
 
@@ -95,10 +94,9 @@
     
     # url for attachment
     if url[0] != '/' and url[0:7] != 'http://' and url[0:8] != 'https://':
-        if url[:11] != 'attachment:':
-            url = 'attachment:%s' % url
-        url = extract_link(formatter.env, formatter.context, '[%s attachment]' % url)
-        url = '/raw-' + url.attrib.get('href')[1:]
+        if url[:11] == 'attachment:':
+            url = url[11:]
+        url = formatter.env.abs_href('/raw-attachment/%s/%s/%s' % (formatter.resource.realm, formatter.resource.id, url))
     
     # embed code
     code = '<object width="%(w)s" height="%(h)s">\

(in reply to: ↑ 3 ) 03/31/10 00:58:08 changed by rudyryk

  • status changed from new to assigned.

Replying to mkc:

The extract_link code now returns a stream instead of one element. The following diff should fix for inputs following forms:

patch applied in r7800. thank you! )

03/31/10 00:58:17 changed by rudyryk

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

Add/Change #6258 ('Fragment' object has no attribute 'attrib')




Change Properties
Action