CompileException when using' '\' for a line continuation

201 views
Skip to first unread message

Jakub Trzaskoma

unread,
Oct 29, 2012, 6:06:33 AM10/29/12
to mako-d...@googlegroups.com
I am getting CompileException every time where '\' is used for a line continuation.
I haven't got such problem before and now it appears from nowhere. Have you got idea got to fix it?
I am using Mako 0.7.2 and python 2.7.2+.

Code:
% if (bookingInfo or launchInfo) and booking.getType() == "Vidyo" and self_._rh._getUser() and booking.isLinkedToEquippedRoom():
  % if conf.canModify(self_._rh._aw) or booking.getOwner()["id"] == self_._rh._getUser().getId() or \
       (self_._rh.getHostIP() == VidyoTools.getLinkRoomIp(booking.getLinkObject(), ipAttName='IP')):
    <span style="margin-left:3px;margin-right:3px;">|</span>
    <a href="#" style="font-size:12px; font-weight: bold;" class="connect_room" data-booking-id="${booking.getId()}"
       data-event="${conf.getId()}" data-location="${booking.getLinkVideoRoomLocation()}">${_("Connect")} ${booking.getLinkVideoRoomLocation()}</a>
    <span style="display:inline; vertical-align:middle" class="progress"></span>
  % endif
% endif

Exception type: <class 'mako.exceptions.CompileException'>
Exception message: Fragment 'if conf.canModify(self_._rh._aw) or booking.getOwner()["id"] == self_._rh._getUser().getId() or \' is not a partial control statement in file '/home/jakub/indico2/cds-indico/MaKaC/plugins/Collaboration/tpls/EventDetailBanner.tpl' at line: 81 char: 1
...
File "/tmp/indico_venv/local/lib/python2.7/site-packages/Mako-0.7.2-py2.7.egg/mako/lookup.py", line 240, in get_template
    return self._load(srcfile, uri)

  File "/tmp/indico_venv/local/lib/python2.7/site-packages/Mako-0.7.2-py2.7.egg/mako/lookup.py", line 306, in _load
    **self.template_args)

  File "/tmp/indico_venv/local/lib/python2.7/site-packages/Mako-0.7.2-py2.7.egg/mako/template.py", line 291, in __init__
    module = self._compile_from_file(path, filename)

  File "/tmp/indico_venv/local/lib/python2.7/site-packages/Mako-0.7.2-py2.7.egg/mako/template.py", line 347, in _compile_from_file
    self.module_writer)

  File "/tmp/indico_venv/local/lib/python2.7/site-packages/Mako-0.7.2-py2.7.egg/mako/template.py", line 628, in _compile_module_file
    generate_magic_comment=True)

  File "/tmp/indico_venv/local/lib/python2.7/site-packages/Mako-0.7.2-py2.7.egg/mako/template.py", line 597, in _compile
    node = lexer.parse()

  File "/tmp/indico_venv/local/lib/python2.7/site-packages/Mako-0.7.2-py2.7.egg/mako/lexer.py", line 233, in parse
    if self.match_control_line():

  File "/tmp/indico_venv/local/lib/python2.7/site-packages/Mako-0.7.2-py2.7.egg/mako/lexer.py", line 427, in match_control_line
    self.append_node(parsetree.ControlLine, keyword, isend, text)

  File "/tmp/indico_venv/local/lib/python2.7/site-packages/Mako-0.7.2-py2.7.egg/mako/lexer.py", line 131, in append_node
    node = nodecls(*args, **kwargs)

  File "/tmp/indico_venv/local/lib/python2.7/site-packages/Mako-0.7.2-py2.7.egg/mako/parsetree.py", line 77, in __init__
    code = ast.PythonFragment(text, **self.exception_kwargs)

  File "/tmp/indico_venv/local/lib/python2.7/site-packages/Mako-0.7.2-py2.7.egg/mako/ast.py", line 78, in __init__
    code, **exception_kwargs)

Michael Bayer

unread,
Oct 29, 2012, 10:55:24 AM10/29/12
to mako-d...@googlegroups.com

On Oct 29, 2012, at 6:06 AM, Jakub Trzaskoma wrote:

> I am getting CompileException every time where '\' is used for a line continuation.
> I haven't got such problem before and now it appears from nowhere. Have you got idea got to fix it?
> I am using Mako 0.7.2 and python 2.7.2+.
>
> Code:
> % if (bookingInfo or launchInfo) and booking.getType() == "Vidyo" and self_._rh._getUser() and booking.isLinkedToEquippedRoom():
> % if conf.canModify(self_._rh._aw) or booking.getOwner()["id"] == self_._rh._getUser().getId() or \
> (self_._rh.getHostIP() == VidyoTools.getLinkRoomIp(booking.getLinkObject(), ipAttName='IP')):
> <span style="margin-left:3px;margin-right:3px;">|</span>
> <a href="#" style="font-size:12px; font-weight: bold;" class="connect_room" data-booking-id="${booking.getId()}"
> data-event="${conf.getId()}" data-location="${booking.getLinkVideoRoomLocation()}">${_("Connect")} ${booking.getLinkVideoRoomLocation()}</a>
> <span style="display:inline; vertical-align:middle" class="progress"></span>
> % endif
> % endif


this above template compiles fine for me. Support for a backslash working with conditionals was added a long time ago, in version 0.1.6. Maybe check your Mako version.


Jakub Trzaskoma

unread,
Oct 30, 2012, 5:09:24 AM10/30/12
to mako-d...@googlegroups.com

On Monday, October 29, 2012 3:55:09 PM UTC+1, Michael Bayer wrote:

this above template compiles fine for me.  Support for a backslash working with conditionals was added a long time ago, in version 0.1.6.   Maybe check your Mako version.

 
Thanks for your answer.
I am using Mako 0.7.2. I tried with older version. I also tried to re-install Mako. I even installed everything once again in new virtualenv but it did not help.
The weird thing about this is that I am only person who has this problem. Everything is working fine for other team members on theirs PC's.
Any other suggestions? Maybe there is a problem with other libraries which affect Mako?

Mike Bayer

unread,
Oct 30, 2012, 11:20:28 AM10/30/12
to mako-d...@googlegroups.com
is your virtualenv using --no-site-packages ?    is there a systemwide Mako sneaking in ?





--
You received this message because you are subscribed to the Google Groups "Mako Templates for Python" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mako-discuss/-/z1IeSGJTO7QJ.
To post to this group, send email to mako-d...@googlegroups.com.
To unsubscribe from this group, send email to mako-discuss...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mako-discuss?hl=en.

Reply all
Reply to author
Forward
0 new messages