Hi,

I am learning about using xml files in web2py and have some questions.

This controller allows me to view an xml file,

from gluon.tools import Expose
import osdef showtree3():
    expath = '/Users/mgreaney/examples/ex_01.xml'
    return dict(files=Expose(expath))

This allows me to view the xml file in a view
with index containing {{=files}}, but I want to collect the xml file as 
raw POST data.

I found this info on the "old web2py blog":

ontroller code:
def indexxml():   # changed name from index to indexxml
    response.headers['content-type'] = 'text/xml'
    xml = request.body.read()  # retrieve the raw POST data
    if len(xml) == 0:
        xml = '<?xml version="1.0" encoding="utf-8" ?><root>no post 
data</root>'
    return response.render(dict(xml=XML(xml)))

# View code:
{{=xml}}

and then it says to try using curl to call the controller like this,

curl --data '<?xml version="1.0"><root>my xml data</root>' 
http://example.com/app/controller/index

and when I use curl from the command line like this,
curl --data '<?xml version="1.0"><root>my xml data</root>' 
http://127.0.0.0:8000:/myapp/static/ex_01.xml

I can see the contents of ex_01.xml

but if I run this from the command line,
curl --data '<?xml version="1.0"><root>my xml data</root>' 
http://127.0.0.0:8000:/myapp/maketree/indexxml

I get the output of the view "index.html" for the maketree controller, 
which just has some brief text content and not any output from 
indexxml.html.

I don't understand how the indexxml in the example above gets the xml file 
as input?

How do I use request.body and request.body.read()?

Is there a  way to get raw POST data from an xml file that is in my static 
directory 
using request.body?

Also, can you use curl from inside a controller? I get a syntax error if I 
try this.

Can I use a modified version of the end info at this post?
https://groups.google.com/forum/?hl=en#!searchin/web2py/curl/web2py/efrSxAT9AnU/NlGub7WvlfAJ
Thanks!

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to