Configurar una vista como tipo 'text/xml'

Miuler <[email protected]> Sat, 6 Feb 2010 12:03:35 -0500
Newsgroups gmane.comp.web.zope.repoze.devel,gmane.comp.python.general.castellano
Message-ID <[email protected]>
--===============0923911863==
Content-Type: multipart/alternative; boundary=00504502c9fda48cf5047ef18d4f

--00504502c9fda48cf5047ef18d4f
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

(http://paste.pocoo.org/show/04xY0CQb2YpOy3gMGSFy/)

Hola, tengo una clase vista la cual me proporciona los m=C3=A9todos para la
plantilla:

class ReportXmlView(object):
    def __init__(self, context, request):
        self.context =3D context
        self.request =3D request

    def __call__(self):
        return {}

    def getReportsFromDB(self):
        """example"""
        id_user =3D self.request.params['id_user']
        reports =3D [1,2,3,4,5]

lo tengo todo configurado con zcml de la siguiente manera
<view
  name=3D"report.xml"
  for=3D"*"
  view=3D".view.ReportXmlView"
  renderer=3D"report.xml.pt"
  />

Pero esto me retorna content type text/html, y yo quiero que retorne un
text/xml
He intentado poner esto:
<view
  name=3D"report.xml"
  for=3D"*"
  view=3D".view.ReportXmlView"
  renderer=3D"report.xml.pt"
  header=3D"Content-Type:text/xml"
  />

Pero no funciona, como puedo hacer para que retorne un type "text/xml"
mediante zcml??

Por el momento he quitado y lo he puesto por codigo

class ReportXmlView(object):
    def __init__(self, context, request):
        self.context =3D context
        self.request =3D request

    def __call__(self):
        response =3D render_template_to_response('report.xml.pt', view=3Dse=
lf)
        response.content_type =3D 'text/xml'
        return response

    def getReportsFromDB(self):
        """example"""
        id_user =3D self.request.params['id_user']
        reports =3D [1,2,3,4,5]

<view
  name=3D"report.xml"
  for=3D"*"
  view=3D".view.ReportXmlView"
  />

--00504502c9fda48cf5047ef18d4f
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div><div><div><span class=3D"Apple-style-span" style=3D"font-size: x-small=
;">(</span><a href=3D"http://paste.pocoo.org/show/04xY0CQb2YpOy3gMGSFy/"><s=
pan class=3D"Apple-style-span" style=3D"font-size: x-small;">http://paste.p=
ocoo.org/show/04xY0CQb2YpOy3gMGSFy/</span></a><span class=3D"Apple-style-sp=
an" style=3D"font-size: x-small;">)</span></div>

<div><br></div><div>Hola, tengo una clase vista la cual me proporciona los =
m=C3=A9todos para la plantilla:</div><div><br></div><div>class ReportXmlVie=
w(object):</div><div>=C2=A0=C2=A0 =C2=A0def __init__(self, context, request=
):</div><div>=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0self.context =3D context</div=
>

<div>=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0self.request =3D request</div><div><b=
r></div><div>=C2=A0=C2=A0 =C2=A0def __call__(self):</div><div>=C2=A0=C2=A0 =
=C2=A0 =C2=A0 =C2=A0return {}</div><div><br></div><div>=C2=A0=C2=A0 =C2=A0d=
ef getReportsFromDB(self):</div><div>=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0&quot=
;&quot;&quot;example&quot;&quot;&quot;</div>

<div>=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0id_user =3D self.request.params[&#39;=
id_user&#39;]</div><div>=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0reports =3D [1,2,3=
,4,5]</div><div><br></div><div>lo tengo todo configurado con zcml de la sig=
uiente manera</div><div>&lt;view</div><div>=C2=A0=C2=A0name=3D&quot;report.=
xml&quot;</div>

<div>=C2=A0=C2=A0for=3D&quot;*&quot;</div><div>=C2=A0=C2=A0view=3D&quot;.vi=
ew.ReportXmlView&quot;</div><div>=C2=A0=C2=A0renderer=3D&quot;<a href=3D"ht=
tp://report.xml.pt">report.xml.pt</a>&quot;</div><div>=C2=A0=C2=A0/&gt;</di=
v><div><br></div><div>Pero esto me retorna content type text/html, y yo qui=
ero que retorne un text/xml</div>

<div>He intentado poner esto:</div><div>&lt;view</div><div>=C2=A0=C2=A0name=
=3D&quot;report.xml&quot;</div><div>=C2=A0=C2=A0for=3D&quot;*&quot;</div><d=
iv>=C2=A0=C2=A0view=3D&quot;.view.ReportXmlView&quot;</div><div>=C2=A0=C2=
=A0renderer=3D&quot;<a href=3D"http://report.xml.pt">report.xml.pt</a>&quot=
;</div>

<div>=C2=A0=C2=A0header=3D&quot;Content-Type:text/xml&quot;</div><div>=C2=
=A0=C2=A0/&gt;</div><div><br></div><div>Pero no funciona, como puedo hacer =
para que retorne un type &quot;text/xml&quot; mediante zcml??</div><div><br=
></div><div>Por el momento he quitado y lo he puesto por codigo</div>

<div><br></div><div>class ReportXmlView(object):</div><div>=C2=A0=C2=A0 =C2=
=A0def __init__(self, context, request):</div><div>=C2=A0=C2=A0 =C2=A0 =C2=
=A0 =C2=A0self.context =3D context</div><div>=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=
=A0self.request =3D request</div><div><br></div><div>=C2=A0=C2=A0 =C2=A0def=
 __call__(self):</div>

<div>=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0response =3D render_template_to_respo=
nse(&#39;<a href=3D"http://report.xml.pt">report.xml.pt</a>&#39;, view=3Dse=
lf)</div><div>=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0response.content_type =3D &#=
39;text/xml&#39;</div><div>=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0return response=
</div>

<div><br></div><div>=C2=A0=C2=A0 =C2=A0def getReportsFromDB(self):</div><di=
v>=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;&quot;&quot;example&quot;&quot;&qu=
ot;</div><div>=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0id_user =3D self.request.par=
ams[&#39;id_user&#39;]</div><div>=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0reports =
=3D [1,2,3,4,5]</div>

<div><br></div><div>&lt;view</div><div>=C2=A0=C2=A0name=3D&quot;report.xml&=
quot;</div><div>=C2=A0=C2=A0for=3D&quot;*&quot;</div><div>=C2=A0=C2=A0view=
=3D&quot;.view.ReportXmlView&quot;</div><div>=C2=A0=C2=A0/&gt;</div><div><b=
r></div></div></div>

--00504502c9fda48cf5047ef18d4f--

--===============0923911863==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Repoze-dev mailing list
Repoze-dev-Gjhu/[email protected]
http://lists.repoze.org/listinfo/repoze-dev

--===============0923911863==--