Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #515 (closed defect: fixed)

Opened 13 years ago

Last modified 13 years ago

[PATCH] New widget API repeats javascript links

Reported by: alberto@… Owned by: anonymous
Priority: normal Milestone: 0.9
Component: TG Widgets Version:
Severity: normal Keywords:
Cc:

Description

When a new style widget has JSLinks, these are inserted multiple times at body_top, body_bottom and head

Attachments

widgets_js.patch Download (612 bytes) - added by michele 13 years ago.
A patch

Change History

comment:1 Changed 13 years ago by michele

I'm going to take a quick look to see why this is happening.

comment:2 Changed 13 years ago by michele

Damn, I've found the problem, the js dict (in controllers.py) is using the same list for every location:

>>> js = dict().fromkeys(js_location, setlike())
>>> js
{head: [], bodytop: [], bodybottom: []}
>>> js[js_location.head].add(2)
>>> js
{head: [2], bodytop: [2], bodybottom: [2]}
>>>

Now, the problem is not with setlike but with the fromkeys method used by the dict that's reusing the same value for every key, but the value is a mutable hence is the same reference for every key:

>>> js = dict().fromkeys(js_location, [])
>>> js
{head: [], bodytop: [], bodybottom: []}
>>> js[js_location.head].append(2)
>>> js
{head: [2], bodytop: [2], bodybottom: [2]}
>>>

Anyway the Calendar works (here at least), but was this problem there since the beginning? I didn't notice it.

Changed 13 years ago by michele

A patch

comment:3 Changed 13 years ago by michele

A pretty trivial patch, I'm going to sleep now and can't come up with something better. :D

Seems to work fine.

comment:4 Changed 13 years ago by michele

  • Summary changed from New widget API repeats javascript links to [PATCH] New widget API repeats javascript links

comment:5 Changed 13 years ago by alberto@…

Applied and works! The js at calendarpicker now works fine, I'll update the patch with your suggestions in a moment. Thanks

comment:6 Changed 13 years ago by Jorge Godoy <jgodoy@…>

Sorry for being mean, but does this also solve the I18N problems for calendars? The one where we have to pass the name of the JS to be used as a lazystring?

comment:7 Changed 13 years ago by alberto

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

commited ar r653. Thanks

comment:8 Changed 13 years ago by kevin

Jorge: I don't think this solves that problem.

comment:9 Changed 13 years ago by Jorge Godoy <jgodoy@…>

Kevin: it was solved in a different patch. :-) (I haven't tested, but the implementation seems OK to me, using calendar_lang)

Note: See TracTickets for help on using tickets.