docFactory at Nevow Elements
I am using Nevow's LiveElements and I am gettings troubles with the docFactory attribute. In the examples I've seen, docFactory = loaders.stan(...) I'd like to load a string representing my html page[0] Can this be done? I really don't like stan :) Greets! [0] I generate the string using Django's templates systems' render_to_string function. -- Juanjo Conti blog: http://www.juanjoconti.com.ar
On 08:10 pm, jjconti@gmail.com wrote:
I am using Nevow's LiveElements and I am gettings troubles with the docFactory attribute. In the examples I've seen, docFactory = loaders.stan(...) I'd like to load a string representing my html page[0]
Can this be done? I really don't like stan :)
Greets!
[0] I generate the string using Django's templates systems' render_to_string function.
There's also nevow.loaders.xmlstr. You may not want to bother making a new docFactory for every page render, though. You might want to make a single render function and return the string from that, wrapped in nevow.tags.xml. Jean-Paul
2009/9/30 <exarkun@twistedmatrix.com> [snip]
There's also nevow.loaders.xmlstr.
You may not want to bother making a new docFactory for every page render, though. You might want to make a single render function and return the string from that, wrapped in nevow.tags.xml.
Excelent! docFactory = loaders.stan(T.xml(render_to_string('ter.html', {}))) -- Juanjo Conti blog: http://www.juanjoconti.com.ar
2009/9/30 Juanjo Conti <jjconti@gmail.com>
2009/9/30 <exarkun@twistedmatrix.com> [snip]
There's also nevow.loaders.xmlstr.
You may not want to bother making a new docFactory for every page render, though. You might want to make a single render function and return the string from that, wrapped in nevow.tags.xml.
Excelent!
docFactory = loaders.stan(T.xml(render_to_string('ter.html', {})))
Not so fast. This 2 lines donot generate the same page :( docFactory = xmlfile(sibpath(__file__, 'ter.html')) docFactory = loaders.stan(T.xml(render_to_string('ter.html', {}))) -- Juanjo Conti blog: http://www.juanjoconti.com.ar
Any document about how does docFactory actually work? 2009/9/30 Juanjo Conti <jjconti@gmail.com>
2009/9/30 Juanjo Conti <jjconti@gmail.com>
2009/9/30 <exarkun@twistedmatrix.com> [snip]
There's also nevow.loaders.xmlstr.
You may not want to bother making a new docFactory for every page render, though. You might want to make a single render function and return the string from that, wrapped in nevow.tags.xml.
Excelent!
docFactory = loaders.stan(T.xml(render_to_string('ter.html', {})))
Not so fast.
This 2 lines donot generate the same page :(
docFactory = xmlfile(sibpath(__file__, 'ter.html')) docFactory = loaders.stan(T.xml(render_to_string('ter.html', {})))
-- Juanjo Conti blog: http://www.juanjoconti.com.ar
-- Juanjo Conti blog: http://www.juanjoconti.com.ar
Can I change doc_factory in the __init__ method of MyLiveElement? 2009/9/30 Juanjo Conti <jjconti@gmail.com>:
Any document about how does docFactory actually work?
2009/9/30 Juanjo Conti <jjconti@gmail.com>
2009/9/30 Juanjo Conti <jjconti@gmail.com>
2009/9/30 <exarkun@twistedmatrix.com> [snip]
There's also nevow.loaders.xmlstr.
You may not want to bother making a new docFactory for every page render, though. You might want to make a single render function and return the string from that, wrapped in nevow.tags.xml.
Excelent!
docFactory = loaders.stan(T.xml(render_to_string('ter.html', {})))
Not so fast.
This 2 lines donot generate the same page :(
docFactory = xmlfile(sibpath(__file__, 'ter.html')) docFactory = loaders.stan(T.xml(render_to_string('ter.html', {})))
-- Juanjo Conti blog: http://www.juanjoconti.com.ar
-- Juanjo Conti blog: http://www.juanjoconti.com.ar
-- Juanjo Conti blog: http://www.juanjoconti.com.ar
2009/10/7 Juanjo Conti <jjconti@gmail.com>:
Can I change doc_factory in the __init__ method of MyLiveElement?
Yes. It' ok. class TempElement(LiveElement): #docFactory = xmlfile(sibpath(__file__, 'ter.html')) jsClass = u'TempDisplay.TempWidget' def __init__(self, sitio='', robot=''): self.sitio = sitio self.robot = robot self.client = [c for c in factory.clients.values() if c['sitio'].ccc == robot.sitio.ccc][0]['self'] configuracion = robot.robotconfig_set.all() entradasanalogicas = [c for c in configuracion if c.tipoio.esEA()] registros = [c for c in configuracion if c.tipoio.esRE()] salidasdigitales = [c for c in configuracion if c.tipoio.esSD()] entradasdigitales = [c for c in configuracion if c.tipoio.esED()] s = render_to_string('tero.html', {'robot': self.robot, 'entradasanalogicas': entradasanalogicas, 'registros': registros, 'salidasdigitales': salidasdigitales, 'entradasdigitales': entradasdigitales}).encode('utf-8') self.docFactory = loaders.xmlstr(s) super(TempElement, self).__init__() -- Juanjo Conti blog: http://www.juanjoconti.com.ar
participants (2)
-
exarkun@twistedmatrix.com
-
Juanjo Conti