On 10/2/06, adamjspooner <[EMAIL PROTECTED]> wrote:
>
> > Do you mean that you do not understand how to pass the data to the
> > template for display, or something else?
>
> Waylan,
>
> I mean I don't understand how to pass the data from my Django app to my
> PHP webservice and then let the user know that everything went ok or
> post errors if it didn't.

Oh, you want to send data to a php webservice, not get data from it.
You'll still want to use urllib2 [1] as Gabor suggested. You will need
to determine if the php web service accepts data via GET or POST (see
below) and use the appropriate method. Assuming, POST, including code
like this simple example [2] in your view should do the trick. For an
example using GET, just keep reading that document for other examples.
Just add an `if` statement to the end to check the result for
success/failure and act accordingly.

[1]: http://docs.python.org/lib/module-urllib2.html
[2]: http://www.voidspace.org.uk/python/articles/urllib2.shtml#data

I'll assume you aren't sure of how to determine between GET and POST,
so visit the website that offers the service you plan to use and find
the page that contains the form to submit data. In your browser view
the source of that page and find the html form. The first line of that
form should look something like this:

    <form action="/foo/bar/" method="post">

The above form uses the POST method. If method="get", then it uses the
GET method. It is possible that the service accepts both regardless if
which is being used. If so, I'd recommend going with POST. Also note
that the url you point urllib2 at will be the the url of `action`, not
the url of the form (if they differ).

>
> I studied the same documentation you suggested over the weekend as well
> as the forms documentation. I can't seem to get my form from Django to
> communicate with my PHP webservice. I've tried setting the
> action="url/to/webservice/" with no luck (naming discrepancies I
> assume). I haven't tried the route that most likely will work,
> manipulating the data between the two from within a view because I
> don't know how. I've been working on it today...still...little progess.

You should probably get the code that submits the data working first.
Try something similar to the examples provided above right in the
python shell. When you find code that works, just copy that into your
view and you should be good to go.



-- 
----
Waylan Limberg
[EMAIL PROTECTED]

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to