I would appreciate some help here.
Google checkout has many ways to send it checkout data. I am using the XML server-to-server.
I have everything ready and now I want to throw some xml at google. I have been doing some reading and I know of a couple of ways to do this, one with urllib, another with pyCurl, but I am using django over here and I searched the Django api for some way to POST data to another site and I havent fallen upon anything. I really would like to use the django way, if there is one because I feel it would be more fluid and right, but if you all don't know of any way I will probably use urllib.
urllib2 is the appropriate way to post data if you're looking for python standard library. Django doesn't provide a specific method to do this (as well as it shouldn't). Django goes out of it's way to not simply reinvent tools that already exist in the the standard library (except email...), so you should never really fear using something out of the python standard library.
requests is also great, but not standard library. Nothing wrong with that though.
Related
I have written a python file with several functions. Now I'm writting a web page where I want to call a function of the file that I mentioned before, by pressing a button but I don't know how.
Can someone help me, or telling me where can I look for some example where python and html are connected.
I'm going to talk only about a front end solution , well known solution for back end only exist (Django) and the others will certainly talk about it.
Beforehand, you should know that using Python as a front end web language is very strange.
The "King" of these languages is JavaScript, and if you want to go further with web development, especially with front end frameworks (AngularJS, react), you should probably learn it.
That being said, there is a way to achieve what you want.
Either with this Python framework, or with a transpiler.
First, you need to set up a server to handle HTTP requests.
Then, something that can interpret python codes is needed. mod_wsgi is a good choice for python. But for a simpler way, you can also use CGI (take a look here).
Edit:
A more complete/structured solution is using a python web framework. For instance, Django or Flask. But be prepared to spend more time on them.
My answer is quite specific to the Betfair API however I would like to know how to use more APIs in general. I'm quite new to this sort of thing so don't really know how it works. I've just downloaded this package: https://github.com/jmcarp/betfair.py
My question is, how am I supposed to know the functions that come associated with it? How am I supposed to be able to know how to pull the data that I want from any given website without having any resource describing the functionality of the API?
These library is only a binding (with several errors) to Betfair APIs.
You can find documentation about this API, and therefore about this library, in Developer's web.
If you're interested in how to use Betfair APIs in Python you can take a look at Betfair's code samples.
I am trying to do some research on the wikipedia data, I am good at Python.
I came across this library, seems nice: https://pypi.python.org/pypi/wikipedia/
I don't want to hit wikipedia directly as this is slow, and also I am trying to access a lot of data and might run into their API limits.
Can I somehow hack this to make it access a local instance of wikipedia data. I know I can run a whole wikipedia server and try to do that, but that seems a round about way.
Is there a way to just point to the folder and get this library to work as it does. Or are you aware of any other libraries that do this?
thank you.
I figured out what I need. I think I shouldn't be searching for API, what I am looking for is a parser. Here are a couple options I have narrowed down so far. Both seem like solid starting points.
wikidump:
https://pypi.python.org/pypi/wikidump/0.1.2
mwlib:
https://pypi.python.org/pypi/mwlib/0.15.14
Update: While these are good parsers for wikipedia data, I found them too limiting in one way or the other, not to mention the lack of documentation. So I eventually went with good old python ElementTree and directly work with the XML.
I love #rbates CanCan ruby library for authorization. Was wondering if anything similar existed for python / flask ?
I guess there are three main requirements:
simple declarative way of defining abilities (here is how CanCan does it)
decorator for flask routes
fine-grained way for checking abilities in other parts of the code. i.e. if current_user.can('post::edit') or something
Or, what is the one obvious way to do it? (PEP-20)
Current Options:
Flask Simple Authorization (leaning towards something like this for now.)
Flask Principal (They all feel a bit heavy weight to me)
One year later, I ended up writing one:
https://github.com/jtushman/bouncer
https://github.com/jtushman/flask-bouncer
I recommend you keep an eye on Cork. Currently it's an authentication and authorization framework just for Bottle, but on the roadmap is Flask support. Pretty awesome.
I saw this package in a LinkedIn post a while back.
I never really checked it out, but it looked to have constant updates
Authomatic is an authorization / authentication client library for Python web applications inspired by Alex Vagin’s Simpleauth. In fact, I almost named it Deadsimpleauth, but that name would be too long for a succinct library.
http://peterhudec.github.io/authomatic/
https://github.com/peterhudec/authomatic
Not sure if this is exactly what your looking for, but you might want to take a look at Flask-Auth. http://pythonhosted.org/Flask-Auth/
This might be what you're looking for. It has a decorator, and a current_user object you can access and add methods to.
https://flask-login.readthedocs.org/en/latest/
I want to integrate Zanox feeds in a Django project. Unfortunately there seem to be no client library implementations in Python.
Or are there?
What is the next best alternative to a Python library? Using the Ruby version?
Would have been useful to say what Zanox was in your question. For those interested, they appear to be an advertising network.
Anyway, they do seem to expose a pretty simple XML or JSON feed, as documented here. It looks pretty simple to get that using urllib2 or requests and parse it using json.load.
You can use https://pypi.python.org/pypi/python-zanox-api/ in a custom management command.