Ticket #1442 (closed bug: fixed)

Opened 7 years ago

Last modified 7 years ago

Error in the translation of methods to javascript

Reported by: apoirier Owned by: apoirier
Priority: major Component: renderers
Version: 0.3.0 Keywords:
Cc:

Description

A function can be automatically translated to javascript:

def greet():
   window.alert('Hello world!')

class MyComponent(object):
   pass

@presentation.render_for(MyComponent)
def render(self, h, *args):
   return h.input(type='submit', onclick=greet)

But the translation of a method:

class MyComponent(object):
   def greet(self):
       window.alert('Hello world!')

@presentation.render_for(MyComponent)
def render(self, h, *args):
   return h.input(type='submit', onclick=self.greet)

raises an IndentationError exception:

...
File '/Volumes/data/projects/nagare/dev/src/nagare/core/nagare/namespaces/xhtml.py', line 68 in add_attribute
  xml.add_attribute(self, name, ajax.JS(value))
File '/Volumes/data/projects/nagare/dev/src/nagare/core/nagare/ajax.py', line 339 in __init__
  self.javascript = str2js(src, module)
File '/Volumes/data/projects/nagare/dev/src/nagare/core/nagare/ajax.py', line 300 in str2js
  pyjs.Translator(namespace, compiler.parse(src), output)
File '/opt/stackless-2.6.2/lib/python2.6/compiler/transformer.py', line 51 in parse
  return Transformer().parsesuite(buf)
File '/opt/stackless-2.6.2/lib/python2.6/compiler/transformer.py', line 128 in parsesuite
  return self.transform(parser.suite(text))
IndentationError: unexpected indent (line 1)

Change History

comment:1 Changed 7 years ago by apoirier

  • Status changed from new to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.