Set up a view as type 'text / xml'?

Hello, I have a class which I view provides methods for the template:

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

    def __call__(self):
        return {}

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

I have everything configured as follows zcml
<view
  name="report.xml"
  for="*"
  view=".view.ReportXmlView"
  renderer="report.xml.pt"
  />

But this I returned content type text / html, and I want that returns a text
/ xml
I tried to put this:


I tried to put this:
<view
  name="report.xml"
  for="*"
  view=".view.ReportXmlView"
  renderer="report.xml.pt"
  header="Content-Type:text/xml"
  />

But it works, how can I make returns a type "text / xml" through zcml?

So far I have removed and put it by code

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

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

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

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



2010/2/6 Miuler <miu...@gmail.com>

> (http://paste.pocoo.org/show/04xY0CQb2YpOy3gMGSFy/)
>
> Hola, tengo una clase vista la cual me proporciona los m├ętodos para la
> plantilla:
>
> class ReportXmlView(object):
>     def __init__(self, context, request):
>         self.context = context
>         self.request = request
>
>     def __call__(self):
>         return {}
>
>     def getReportsFromDB(self):
>         """example"""
>         id_user = self.request.params['id_user']
>         reports = [1,2,3,4,5]
>
> lo tengo todo configurado con zcml de la siguiente manera
> <view
>   name="report.xml"
>   for="*"
>   view=".view.ReportXmlView"
>   renderer="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="report.xml"
>   for="*"
>   view=".view.ReportXmlView"
>   renderer="report.xml.pt"
>   header="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 = context
>         self.request = request
>
>     def __call__(self):
>         response = render_template_to_response('report.xml.pt', view=self)
>         response.content_type = 'text/xml'
>         return response
>
>     def getReportsFromDB(self):
>         """example"""
>         id_user = self.request.params['id_user']
>         reports = [1,2,3,4,5]
>
> <view
>   name="report.xml"
>   for="*"
>   view=".view.ReportXmlView"
>   />
>
>
_______________________________________________
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev

Reply via email to