Python is my favorite programming language, the reason for this blog post is just my curiosity.
There are few ways how to make python work with SAP.
But what about a connection to gateway using OData?
There are documents about connecting to gateway for PHP, Java Script, Flex, .NET, Objective C in SAP NetWeaver Gateway Developer Center. But where is Python?
I started to look for an odata library and found two reasonable options:
Web.py is a small python framework for creating web applications. Integration was simple - install pyslet, import a module and you are can start consuming an OData service. I created small hello world application that fetches product list and displays product names.
Header:
from pyslet.odata2.client import Client
Handling class:
class index:
def GET(self):
c=Client("http://services.odata.org/V2/Northwind/Northwind.svc/")
products=c.feeds['Products'].OpenCollection()
productNames = []
for k,p in products.iteritems():
productNames.append(p['ProductName'].value)
web.header('Content-Type', 'text/html')
return render_template('index.html', products = productNames)
Template:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Python + ODATA</title>
</head>
<body>
<table border="1">
<tr><td><strong>Name</strong></td></tr>
{% for name in products %}
<tr><td>{{name}}</td></tr>
{% endfor %}
</table>
</body>
</html>
And the result:
I used information from author's blog - http://swl10.blogspot.com/. More useful and detail information can be found there.
This was just a simple experiment. Author claims that the module does not work with HTTPS OData service, so basically it cannot be used in real environment.
Next challenge? HTTPS source and more sophisticated application!
Small update: I have been playing around with django at JavaScript Jobs and as a hobby project, I would like to try create odata plugin for django. If is someone willing to help me let me know.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
20 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
6 | |
5 | |
5 |