Opened 5 years ago

Closed 5 years ago

#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):


How to reproduce

Create following file with the name 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.

Change History (2)

comment:1 Changed 5 years ago by sebastian

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

comment:2 Changed 5 years ago by sebastian

  • Blocking 2432 removed
  • Resolution set to fixed
  • Status changed from reviewing to closed
Note: See TracTickets for help on using tickets.