Opened on 04/29/2015 at 12:00:32 PM

Closed on 04/30/2015 at 08:41:01 PM

#2434 closed defect (fixed)

[cms] Custom filters and global functions can not be instance methods

Reported by: sebastian Assignee: sebastian
Priority: P3 Milestone:
Module: Sitescripts Keywords:
Cc: Blocked By:
Blocking: Platform: Unknown
Ready: yes Confidential: no
Tester: Verified working: no
Review URL(s):

http://codereview.adblockplus.org/6439782653624320

Description

How to reproduce

Create following file with the name foobar.py either in the globals or filters subdirectory:

class Foo:
  def bar(self):
    return 42

foobar = Foo().bar

Observed behaviour

You get following Python exception when generating pages or running the development server:
AttributeError: 'instancemethod' object has no attribute 'module_ref'

The cms assigns the module to an attribute of the function to prevent the module from beeing cleaned up, while the function might still be called. But it's not possible to dynamically add attributes to instance methods.

Expected behaviour

It should be possible to use instance methods as template filters and functions. Therefore the module should be persisted in a way that doesn't involve adding an attribute to the function.

Attachments (0)

Change History (2)

comment:1 Changed on 04/29/2015 at 12:03:12 PM by sebastian

  • Review URL(s) modified (diff)
  • Status changed from new to reviewing

comment:2 Changed on 04/30/2015 at 08:41:01 PM by sebastian

  • Blocking 2432 removed
  • Resolution set to fixed
  • Status changed from reviewing to closed

Add Comment

Modify Ticket

Change Properties
Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from sebastian.
 
Note: See TracTickets for help on using tickets.