Re: docFactory at Nevow Elements

Juanjo Conti <[email protected]>
Newsgroups gmane.comp.python.twisted.web
Message-ID <[email protected]>
2009/10/7 Juanjo Conti <[email protected]>:
> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.