Can PyAMF support deploying a service using the file system?
I am evaluating PyAMF to replace our existing PHP (ugh) AMF services infrastructure, and I cannot find one important piece of information that would allow me to provide a compelling use case for change:
Currently, new PHP AMF services are deployed simply by placing .php files on the file system; the next time you access them, the new service is in the game. Removing a service is as simple as removing the .php file that provided it, and updating accordingly is simple. I need the same ease of deployment from PyAMF. If we have to rewrite our installers to deploy these services, it will be unstarted.
So what I need to know is if PyAMF can support new service discovery using the filesystem, can it support updating and deleting services the same, and if so what is the best way to configure it to do this?
I am open to any of the various server options; I can easily use cherry, django, whatever was installed and running on its own, and even - with a little more sturm nd drang - mod_python or mod_wsgi are available.
a source to share
web2py includes pyamf support. The way it works is you create functions like
def add(a,b): return a+b
and then you decorate them with @ service.amfrpc3 ('domain')
@service.amfrpc3('domain')
def add(a,b): return a+b
You don't need to restart the web server or do anything else. You just add and remove functions in your controller file (the file where you define services) and the service is made available or removed. You can also use the same function using other protocols (xmlrpc, jsonrpc, rss, csv, xml, json) using multiple decorators.
@service.xmlrpc
@service.jsonrpc
@service.amfrpc3('domain')
def add(a,b): return a+b
You don't need to instantiate the gateway (as with other frameworks). All decorated functions are exposed through one action that you don't need to write because it is already in the scaffolding app (generated with web2py for you):
def call(): return service()
Functions can access the web2py database abstraction layer (and with some restrictions) of the web2py authentication mechanism.
You can edit the controller that contains this function using the shell (emacs / vi / etc), but you can also use the web2py web framework (called "admin") and add services using a browser.
Web2py includes a ticketing system so it's easy to debug web services. Any error on the server side results in tickets. The admin has a web page that lists all the tickets. You click on one and it shows the code that caused the problem and the full traceback.
You can import and use any third party python module. You must have a pre-installed pi.
This is well described in chapter 9 of the book:
http://web2py.com/book/default/section/9/2
Web2py applications are very easy to deploy. One way is with point and click with admin. Another way is to simply copy files from one machine to another. No metadata, no setup procedure (not even for Web2py itself), no settings, no configuration files. The latter process is described somewhat here:
http://gluonframework.wordpress.com/2010/03/02/shell-only-web2py/
web2py is WSGI based. It runs from any web server you can think of (apache + mod_wsgi / mod_python / mod_proxy; lighttpd / cheorkeey / ngnix + fcgi / wsgi.py; cherrypy, etc.). Some parameters are detailed here:
http://www.web2py.com/book/default/section/11/0
Other options can be found at http://web2pyslices.com
Web2py also comes with its own Rocket web server, which is https-enabled and very fast. The web2py code can also be deployed to Google App Engine.
Check the activity in the google web2py group.
a source to share
I am using PyAMF along with Django. A possible solution might look something like this:
- Create a python module containing all of your various py files to work with AMF.
- Create a view that wraps DjangoGateway and initializes all of your services. In this view, you can do the following:
- reload () your service module
- populates a dictionary based on, for example, filenames ({SERVICE_NAME: SERVICE_INSTANCE})
- Create an instance of DjangoGateway using this dictionary and let it handle the incoming request.
This is a hacky solution based on the fact that you can deploy files without any additional steps such as restarting the server.
a source to share