I'm using django, but I like to use it with gwt, well I've try using json with piston and works well, but I prefer using RPC call.
So I know that there's some rpc lib for django, but I'm confused about xml-rpc json-rpc gwt-rpc...
So the questions are:
1) where find a tutorial if exists...
2) or how can I do a simple rpc call in gwt and use django to server side
thanks, I'm asking here because I've find nothing in google thanks
Any particular reason you want to use RPC to Django instead of a web service from GWT application? I think using JSON communication between Django and GWT is much easier than RPC.
The main challenge in using RPC is that your Django and GWT client should communicate via a common protocol. On Django side you need a module that translates the GWT RPC calls to something Django understands and then convert the Django results into something GWT client application understands. In a nutshell RPC calls are serialized text stream sent over http via post method. On the server side you should be able to translate that into the right data structure by deserializing it. So you need a library that will do this serialization and deserialization for Django based on GWT-RPC protocol.
Useful links:
About GWT RPC:
Google documentation : RPC
GWT RPC in a nutshell
GWT + Django:
How to use Django with GWT?
Using GWT with Django using xml
Google Web Toolkit like application in Django
Pyjs
You can also look at http://pyjs.org/ which is a python to JS compiler and use it with Django. The great thing about pyjs is that you are still in Python world :)
http://www.derekschaefer.net/2011/02/08/pyjamas-django-pure-win/
http://gdwarner.blogspot.no/2008/10/brief-pyjamas-django-tutorial.html
Related
I'm having some troubles finding a good way to stablish a communication between my frontend and my backend.
I have a C++ app that deals with the communication with some device, I'd like that my webpage gets the request from the user, then send that request to my always running C++ app, process that request, and then send a response back to my webpage, is there any way to make this happen?
You could use Boost Asio to build a REST server into your C++ app see:
https://www.boost.org/doc/libs/1_55_0/doc/html/boost_asio/examples/cpp11_examples.html
Or you could use a C++ REST framework see:
https://github.com/Microsoft/cpprestsdk
There are a few others as well.
Finally you could build your REST/Web server using some other language such as Java or C# and use a messaging protocol to communicate to your C++ server. You could use sockets or ZeroMQ for example:
http://zeromq.org
A client talks to Django, and django uses node.js to do some javascript related work to give back the client a http response.
I wonder how I should set up the link(?) between the django and node.js.
Simply, I could use python's requests library and talk http, but is this best I can do?
If I were to build the communication link in c++, I would create non-block socket with Send/Recv Thread and use mutex(or similar) between the django view code and the send/recv thread.
I guess that's what is called asynchronous io in node.js world.
Is there a similar thing in python so that I could use on django side to talk to another server?
I heard many big companies use Thrift, would it fit here?
I also see gevent might be relevant keyword here, but not sure.
I am not sure if my answer is still relevant, but I'll give it a try.
IMHO, the best solution for you would be to have a RESTful API for your Django app. This has several advantages:
it provides a lot of decoupling between your Django app and your Node.js one, so in case you ever want to reuse any of them or to replace one of them, it will be easy
it allows you to design an API for each of them and to hide the rest of your implementation (your Django app should not care how Node.js does its job, but only the response that it provides)
there are many great frameworks out there that can help you quickly build your APIs (at leat for Django there is Django REST framework)
If you don't want to build a RESTful API, python's request library is probably the best and easiest way.
Good luck.
My project
I have a backend web application written with Django and a mobile application written with HTML/CSS/jQuery and wrapped in PhoneGap. I need the mobile app to communicate with the web app and I first thought I would build my own REST API.
My understanding
WSGI is a specification (based on HTTP) that defines how to handle communications between a web server and a Python application, basically how to translate HTTP requests into Python objects and vice versa. All we need to provide to the WSGI server (gunicorn for instance) is a WSGI application. In Django we will typically have a wsgi.py file at the root of the project with
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
So Django has a built-in support for the WSGI specification and we, programmers, do not even have to think about how our application interfaces with the web server. Nice.
REST is an architecture style based on 6 constraints defining how data are transmitted between components within a program or separated programs (not necessarily web applications). A RESTful API is an API that fulfills those constraints. I heard that there is a whole framework for Django, surprisingly called django-rest-framework, that helps developers to build REST APIs.
My questions
Hey, why would I need a REST API if the WSGI application already provides a way to parse HTTP requests and return responses? I mean, since my mobile application is nothing less than an embedded webpage, why can't I just use regular urls to access my web application and return HTML code that depends on the type of device that sent the request?
If indeed a REST API is not needed in this case, what is the purpose of a REST API in a Django project? When is it useful?
Well as far as using Django Rest Framework is it has support built in to handle a lot of things like throttling, serializing and de-serializing django query sets into json and back again. It's got built in support to work with django's auth system.
As far as not using it, I suppose there is nothing wrong with having django view methods peruse posted data and serialize to and from json to send responses back, handle authentication, authorization and throttling etc...However that is a crap load of code which you will ultimately need to write for any api and not having to do that is a huge break.
Another benefit to using something like Django Rest Framework is the contribution from the community. Major companies and small companies use it alike. Typically the purpose of an API is to have external parties consume it. Something like Django Rest Framework tries to follow best practices in this regard making it easier for your customers to consume your api.
In Laravel 4 framework, how to create a SOAP based web service. I would like to build a SOA based web application in laravel. Please clarify with an example how to use web service with some step by step examples or links as i am completely new to laravel
Thanks in advance..
You can use "php-wsdl-creator" (also supports SOAP). They have a great tutorial and many demo php files to get you started. It can also easily be implemented in laravel or any other framework for that matter. :)
You can find more information on Google Code: https://code.google.com/p/php-wsdl-creator/
Also note that SOAP requires an extension to be loaded in PHP.
For more recent needs, you should use a Project such as wsdl2phpgenerator or PackageGenerator from WsdlToPhp. This sort of projects, requirable with composer, use an OOP approach and allows to build a SOAP request easily with PHP objects then handle the response just as the request with PHP objects.
both seems to be pretty cool
which is to be in used in what scenario ?
GWT: http://code.google.com/webtoolkit/
Faster AJAX than you'd write by hand
With Google Web Toolkit (GWT), you
write your AJAX front-end in the Java
programming language which GWT then
cross-compiles into optimized
JavaScript that automatically works
across all major browsers.
Django: http://www.djangoproject.com/
a high-level Python Web framework that
encourages rapid development and
clean, pragmatic design.
They have little or nothing to do with each other. Django provides some Javascript; Django can easily handle the server-side of any Ajax conversation.
Django doesn't help you write javascript. It helps you write the server-side of the application.
Django helps you write the HTML pagess (with templates). If the page includes, or relies on Javascript, Django doesn't care very much at all.
pyjamas is a Python port of the GWT, so all the javascript is generated using Python instead of Java.
If you're planning on working with Django it might simplify to make your entire shop code in Python.
It is quite possible to use both in the same project. I've been working on such a project for some time now. Have Django handle the server side and leave the client side to GWT. The only issue I have is that the RPC mechanism in GWT cannot be used because it works with Java servlets. I use JSON for communication instead.
With GWT you write client-side applications, that run inside some browser Javascript engine. You code in Java, and it gets compiled into Javascript.
Django, is different because you write server-side applications: applications will be executed in the server and their result is sent to the client browser. Ah! Django is Python.
Both have libraries to achieve most of the tasks web developer needs, like internationalization, sessions, etc. Django comes with a nice ORM (Object Relational Mapper) and GWT comes with a Tomcat based engine, for the server-side coding and development.
If you need to make a decision just choose the framework based in the language of your choice.
I use xml serialization for communication between django and gwt
http://www.eecho.info/Echo/ajax/requestbuilder-gwt-15/