equal
deleted
inserted
replaced
30 |
30 |
31 from logilab.mtconverter import xml_escape, html_unescape |
31 from logilab.mtconverter import xml_escape, html_unescape |
32 from logilab.common.date import ustrftime |
32 from logilab.common.date import ustrftime |
33 from logilab.common.deprecation import deprecated |
33 from logilab.common.deprecation import deprecated |
34 |
34 |
35 from cubicweb.utils import JSString, json_dumps |
35 from cubicweb.utils import js_dumps |
36 |
36 |
37 |
37 |
38 def rql_for_eid(eid): |
38 def rql_for_eid(eid): |
39 """return the rql query necessary to fetch entity with the given eid. This |
39 """return the rql query necessary to fetch entity with the given eid. This |
40 function should only be used to generate link with rql inside, not to give |
40 function should only be used to generate link with rql inside, not to give |
351 self.args = args |
351 self.args = args |
352 self.parent = parent |
352 self.parent = parent |
353 def __unicode__(self): |
353 def __unicode__(self): |
354 args = [] |
354 args = [] |
355 for arg in self.args: |
355 for arg in self.args: |
356 if isinstance(arg, JSString): |
356 args.append(js_dumps(arg)) |
357 args.append(arg) |
|
358 else: |
|
359 args.append(json_dumps(arg)) |
|
360 if self.parent: |
357 if self.parent: |
361 return u'%s(%s)' % (self.parent, ','.join(args)) |
358 return u'%s(%s)' % (self.parent, ','.join(args)) |
362 return ','.join(args) |
359 return ','.join(args) |
363 |
360 |
364 class _JS(object): |
361 class _JS(object): |
376 'cw.pouet(1,"2")' |
373 'cw.pouet(1,"2")' |
377 >>> str(js.cw.pouet(1, "2").pouet(None)) |
374 >>> str(js.cw.pouet(1, "2").pouet(None)) |
378 'cw.pouet(1,"2").pouet(null)' |
375 'cw.pouet(1,"2").pouet(null)' |
379 >>> str(js.cw.pouet(1, JSString("$")).pouet(None)) |
376 >>> str(js.cw.pouet(1, JSString("$")).pouet(None)) |
380 'cw.pouet(1,$).pouet(null)' |
377 'cw.pouet(1,$).pouet(null)' |
|
378 >>> str(js.cw.pouet(1, {'callback': JSString("cw.cb")}).pouet(None)) |
|
379 'cw.pouet(1,{callback: cw.cb}).pouet(null)' |
381 """ |
380 """ |
382 |
381 |
383 def domid(string): |
382 def domid(string): |
384 """return a valid DOM id from a string (should also be usable in jQuery |
383 """return a valid DOM id from a string (should also be usable in jQuery |
385 search expression...) |
384 search expression...) |