I've managed to make some tests on Livepage in Nevow trunk, and I've found a problem. The following code work without problem :
def handle_action(self, ctx): client = livepage.IClientHandle(ctx) client.set("mynode", tags.span["test"])
But the following don't :
def handle_action(self, ctx): client = livepage.IClientHandle(ctx) client.set("mynode", [tags.span["test1"], tags.span["test2"]])
(it prints <span>'test1'</span><span>'test2'</span> instead of '<span>test1</span><span>test2</span>'
This works on nevow 0.4.1. Am I doing something wrong, or is there really a problem ? My knowledge of the flatten mecanism is too poor for tracking the cause of this...
By the way, I'll also look at the callRemote branch that seems to offer great things.
Thanks,
Quoting Thomas HERVE therve@free.fr:
I've managed to make some tests on Livepage in Nevow trunk, and I've found a problem. The following code work without problem :
def handle_action(self, ctx): client = livepage.IClientHandle(ctx) client.set("mynode", tags.span["test"])
But the following don't :
def handle_action(self, ctx): client = livepage.IClientHandle(ctx) client.set("mynode", [tags.span["test1"], tags.span["test2"]])
I reply to myself because I managed to handle this case by adding types.ListType in the __call__ function of livepage._js. But I have another problem : quotes in i18n strings are not escaped. For example if I have :
def handle_action(self, ctx): client = livepage.IClientHandle(ctx) client.set("mynode", [tags.span[_("test1")]])
and a locale file :
msgid "test1" msgstr "I'm test 1"
I have an error.
I don't know if these feedbacks are useful and/or at the right place... but these elements are really important for my use of livepage.
Thomas HERVE wrote:
[...] But I have another problem : quotes in i18n strings are not escaped. For example if I have :
def handle_action(self, ctx): client = livepage.IClientHandle(ctx) client.set("mynode", [tags.span[_("test1")]])
and a locale file :
msgid "test1" msgstr "I'm test 1"
If you can reproduce that without livepage, I can fix it. I can't help with livepage, though. _('test1') returns an object that when flattened becomes the string "I'm test 1". That should be reproducible without with i18n:
class Dummy(object): pass def flatter(o): return "Hi! I've got a quote!" flat.registerFlattener('flatter', 'Dummy')
def handle_action(self, ctx): client = livepage.IClientHandle(ctx) client.set("mynode", [tags.span[Dummy()]])
Quoting Tommi Virtanen tv@twistedmatrix.com:
If you can reproduce that without livepage, I can fix it. I can't help with livepage, though.
Unfortunately (well... or not), it's not a i18n problem, it's really a livepage problem. Livepage didn't handle i18n on 0.4.1 either, but a workaroud was possible (and not too complicated).
_('test1') returns an object that when flattened becomes the string "I'm test 1". That should be reproducible without with i18n:
class Dummy(object): pass def flatter(o): return "Hi! I've got a quote!" flat.registerFlattener('flatter', 'Dummy')
def handle_action(self, ctx): client = livepage.IClientHandle(ctx) client.set("mynode", [tags.span[Dummy()]])
Yes it reproduces the problem. I think you've got the point. Livepage can simple-quote objects when _js called, but it didn't escape it when it's more complex (typically, i18n or own flatten).