Package: ladon
DescriptionLadon is a framework for exposing python methods to several internet service
protocols. Once a method is ladonized it is automatically served through all
the interfaces that your ladon installation contains. Ladon is easily extendable.
Adding a new service interface is as easy as adding a single module containing
a class inheriting the BaseInterface class.Documentation:http://ladon.readthedocs.io/en/latest/Examplefrom ladon.ladonizer import ladonize

class Calculator(object):
        """
        This service does the math, and serves as example for new potential Ladon users.
        In-line documentation ends up in the web service online browsable API
        """
        @ladonize(int,int,rtype=int)
        def add(self,a,b):
                """
                Add two integers together and return the result

                @param a: 1st integer
                @param b: 2nd integer
                @rtype: The result of the addition
                """
                return a+bFeaturesExpose your existing Python code with the @ladonize decoratorSupport for Python 2 and Python 3Support for multiple web service protocolsAutogenerated documetation based on in-line documentationAutogenerated service descriptions (WSDL, JSON-WSP/description)Web service API BrowsingAccess your service and it’s documentation via a web browserTheming support for the API Browser by adding custom skinsDefault skin “bluebox” supports direct web service method testing via the browserJSON-WSP support - ideal for AJAX backendRun web service methods in background with no effort by using Ladon tasksFollowHipChatBugsReport bugs to:https://bitbucket.org/jakobsg/ladon/issues?status=new&status=openContributeThere are plenty of things to do like implementing more interface modules making better service navigation etc. If you are interested in helping out with contributions or even want to join the development team - Go to Ladon’s Bitbucket page:https://bitbucket.org/jakobsg/ladonWhat does Ladon mean?Ladon is a serpent-like dragon from Greek mythology which might be given multiple
heads, a hundred in Aristophanes’ The Frogs (a passing remark in line 475). each
head might speak with different voices.Like Ladon the dragon has many heads that speak with different voices Ladon the
Web Service has many interfaces that communicate with different protocols. Ladon
the dragon only has one body - users only need to implement their service
classes once.ChangesNew in 1.0.7Fixed issue with Content-Length no longer auto-set on file transfers (https://bugs.python.org/issue12319)New in 1.0.5Fixed issue with growing cookies on repeated requests.Removed all ladonize-dot-org referencesNew in 1.0.3Added auto-delete feature for attachment for buffer objects that origin from a filesystemMultipart response payloads delete there temporary filesNew in 1.0.2Fixed MultiPartWriter to use proper EOL notationNew in 1.0.0Added support for multiprocessing making tasktype services implementable over multiple servers.
Interprocess/host communication is supported via memcached or redis.New in 0.9.36Added LOG_JSON_FORMATNew in 0.9.35Bugfix: MultiPartWriter handles encoding in headersNew in 0.9.33Support for multithreading when running services under ladon-ctl testserveNew in 0.9.31Better hints in LadonType raised exceptionsNew in 0.9.30Bugfix: When posting multi-part attachments with no content-id no delete was performed. This is fixedNew in 0.9.26Fixed bug in multiparthandler.py, Boundary sometimes came in with quotes.Fixed bug when exception occured in wsgi_application.New in 0.9.25Added possibility to add headers and cookies to client init and method calls.New in 0.9.24BUGFIX: Probed Language should not be passed to interface description methodNew in 0.9.23Added LADON_ACCEPT_LANGUAGES to keyword args, service methods can use this to get a list of languages accepted by the user.New in 0.9.22Hint added to fault requestsNew in 0.9.21Path fix for built-in skinsNew in 0.9.20Python JSONWSPClient: Get description with HTTP GET methodNew in 0.9.19Support for interface aliasinginterface soapdocumentliteral also accessible via soapNew in 0.9.18Small font changeFixed albumservice exampleNew in 0.9.17jsonwspclient.js: Catch non-JSON responses send serverfault callback to client call-point“bluebox” skin: present server faults as well as service faults“bluebox” skin: present request status code and textNew in 0.9.16Added ladon-ctl She-BangNew in 0.9.15Package data support for both pip and easy_installNew in 0.9.12fixed path problem in LadonWSGIApplicationNew in 0.9.11Added built-in skins “bluebox” and “rounded”New in 0.9.10Added som front-page documentationAdded examples and docs to source package via (MANIFEST.in)Changed theme for documentation to “bootstrap”New in 0.9.9Fix: Version 0.9.0 broke Python 3 support. This has now been fixed and tested with Python 3.4New in 0.9.8Finally introducing Tasks. Earlier on it has been announced that task-type Ladon methods would be the
feature that brings Ladon to version 1.0.0. Indeed that will be the case, but this is kind of a technology
preview.Cave-eats:Uses the threading module meaning that GIL is in playTask state is kept in global python variables and therefore do not work cross-host nor cross-processIn many use-cases these cave-eats are not a problem. Ie. if your task spawns a new synchronious process
like a system-call you will not be having problems with GIL and the current implementation will work as
long as your application stays within the same process.The good thing about the current solution is that it works out-of-the-box without introducing thirdparty
state-keeping services. It should also be noted that if you are using ie. mod-wsgi on apache2 it is
possible to control process groups for specific Ladon services, so you can configure your apache server
to use only one process for your services containing task type Ladon methods, and multiple procesesses for
your other services that do not need to keep state like Ladon tasks.The solution for the cave-eats mentioned will be the option to configure socket-based state caching like
memcached or redis. If using the thirdparty state caching option Ladon will shift over to using the
multiprocessing module for task execution. This solution should solve both cave-eats and will be when
Ladon turns into 1.0.0.The current implementation will probably stay in Ladon because it is very easy to use and requires no
extra configuration other than the keyword in your ladonize decorator - example:from ladon.compat import PORTABLE_STRING
from ladon.ladonizer import ladonize

class TaskService(object):

        @ladonize(PORTABLE_STRING, int, rtype=int, tasktype=True)
        def taskExample(self,session_id,counter,**kw):
                repeat = 5.0
                for i in xrange(int(repeat)):
                        time.sleep(5)
                        kw.get('update_progress')(float(i+1.0)/repeat)
                return counterLadon tasksdocumentationNew in 0.9.3Added set_log_backup_count(), set_log_maxsize()New in 0.9.2Added __version__ to ladon packageNew in 0.9.1Changes to jsonwsp interface:Documentation lines in description are default turned off from this version on.
Force documentation lines into the description by passing include_doc=true into the query stringDescription is now cached in memory per service per thread.New in 0.9.0Added reserved root path  “skins”. If the path preceded with “skins” leads to an existing file it will be
sent back raw. This makes it possible to add javascripts, images and css files to custom skins.Added bluebox with invokable service UI to “examples/appearance”New in 0.8.8Fix: Python3 support for LadonType methodsNew in 0.8.7Fix: The request dictionary was not being expanded while debuggingNew in 0.8.6Debug logging request args now as req_dictNew in 0.8.5Better exception loggingNew in 0.8.4Fixed issues with soap and xmlrpc protocols, so they can load on Python 3 (no call-tests made)Added internal logging of calls to ladonized methods. This feature logs timestamp, execution time
service- and method names, positional- and keyword args, return value and exceptions if they occur.
To enable this feature set loglevel to minimum 6 (debug level): ladon.tools.log.set_loglevel()New in 0.8.3Added the ability to set the logfile to log to: from ladon.tools.log import set_loglevel,set_logfileNew in 0.8.2Replaced oldest SOAP implementation with a contributed implementation with document literal. This version works
with Microsofts .Net SOAP client.Added possibility to use mirror/reflection mechanism on faults so it is possible to trace errors.New in 0.8.1Added reflection to fault response objects so it is possible to trace faults back to specific requestsNew in 0.8.0Added the optional key to method params info in JSONWSP/description. It was somehow removed during previous update.New in 0.7.9Argument default values added to the JSONWSP/descriptionNew in 0.7.7possibility to add styles globally by adding css-files in a folder called “skins” which should be found in your Ladon pathAdd extra styles for the catalog page: skins/catalog-extra.cssAdd extra styls for service pages: skins/service-extra.cssFixed a problem with service class doc. All lines in the class documentation were stripped making it impossible to write reStructuredText directives. now using inspect.cleandoc()New in 0.7.6wsgi_application now responds to @publisher keyword for service and parameter documentationJSONWSPClient: Added the ability to add request headers manually via member dict JSONWSPClient.extra_headersNew in 0.7.3Added service-wide logging fascilities via LadonWSGIApplication’s constructor. Preliminary log levels are:ladon.server.NO_LOGGING = 0ladon.server.LOG_REQUEST_ACCESS = 1ladon.server.LOG_REQUEST_DICT = 2ladon.server.LOG_RESPONSE_DICT = 4ladon.server.LOG_EXECUTION_TIME = 8New in 0.7.2Added the possibility to use choose between different publishing types when writing
inline documentation for the online API documentation. Possible publishers are “raw”,
“pre” and “docutils” - Example:@ladonize([PORTABLE_STRING], rtype=[File])
def download(self,names):
        """
        @publisher: docutils

        - Test
        - Test 2

        +------------+------------+-----------+
        | Header 1   | Header 2   | Header 3  |
        +============+============+===========+
        | body row 1 | column 2   | column 3  |
        +------------+------------+-----------+
        | body row 2 | Cells may span columns.|
        +------------+------------+-----------+
        | body row 3 | Cells may  | - Cells   |
        +------------+ span rows. | - contain |
        | body row 4 |            | - blocks. |
        +------------+------------+-----------+

        Kode eksempel::

                def test(self):
                        print "oijfwe"



        Download multiple files at once. For each name in the <b>names</b> the service
        attempts to find a file in service/upload that matches it. If a name does not
        have a matching file it is ignored.

        @param names: A list of the file names
        @rtype: Returns a list of File objects
        """
        global upload_dir
        response = []
        for name in names:
                f = File()
                f.name = name
                f.data = attachment(open(join(upload_dir,name),'rb'))
                response += [f]
        return responseNew in 0.7.1Fixed bug 974655
Added via proxy feature to the Python jsonwsp clientNew in 0.7.0Fixed bugs 926442 and 926445New in 0.6.7Attribute filtering is a new feature that allows the service developer to define functions
that can be triggered before and after a service method has been executed.Filter functionscan be used to validate or modify attribute values.New in 0.6.6New dictionary based type-definition for LadonType attributes. Until version 0.6.6 all
LadonType attributes had to reference a type or list of type directly. With dictionary type
definitions it is possible for the service developer to pass more detailed properties about
attributes, like documentation lines, default value or whether it is nullable (None) or not.
Old-style LadonType attribute definitions are still valid and therefore this change offers
backwards compatability. The integration of nullable is built into the soap and jsonwsp
interfaces. Example:class Person(LadonType):
        username = PORTABLE_BYTES     # old-style
        groups = [ PORTABLE_BYTES ]
        mobile = {                    # new-style
                'type': PORTABLE_BYTES,
                'nullable': True,
                'doc': "User's mobile number." }
        valid_user = {
                'type': bool,
                'nullable': False,
                'default': False,
                'doc': ['Is user valid.','If not given, the user is invalid.'] }New in 0.6.5Fault handling finally implemented. interfaces must now implement a FaultHandler inheriting
the BaseFaultHandler class. Fault handlers have been implemented for both SOAP and JSONWSP
interfaces.
All exceptions that occure under method invocation are caught by Ladon’s dispatcher and
sent to the interface fault handler. Use ServerFault or ClientFault exceptions implemented in
ladon.exceptions.service to raise either a server fault or to blame a fault on the client.
Other exceptions that might occure under service method invocation are viewed as unmanaged
Server Faults, and converted to such by the dispatcher.New attachment reference format cidx:<index>. This format let’s the client post request that
have references to attachment parts by index rather than Content-Id.New in 0.6.4JSONWSPClient __init__(description=None,url=None) takes description url as first argument or
keyword “description”. A new keyword argument “url” can be passed instead of description if
the jsonwsp API is known. The tradeoff of using the url is that there are not created any
placeholder methods on the JSONWSPClient object, instead you must call methods via the
call_method() method.CustomResponse - Ladon now offers the ability to define custom response on specified methods.
For instance you can make Ladon respond with a browser download response on a specific service
method. Example:class HTTPAttachmentResponse(CustomResponse):
        def __init__(self,fileobj,filename,filesize,blocksize=4096):
                self.fileobj = fileobj
                self.filename = filename
                self.filesize = filesize
                self.blocksize = blocksize

        def response_headers(self):
                # TODO: Handle encodings for filenames
                return [
                        ('Content-Disposition','attachment; filename="%s"' % self.filename.encode('utf-8')),
                        ('Content-Type','application/force-download'),
                        ('Content-Length',str(self.filesize))]

        def response_data(self):
                return iter(lambda: self.fileobj.read(self.blocksize), '')Bug 852234 - Removed nillable and minOccurs attributes from SOAP part elements.Bug 861193 - Removed ‘_’ to ‘-’ conversion for complexType elements.Bug 884431 - Fixed boolean type on SOAP response objects.New in 0.6.3Nicer query-string handling in wsgi_application.pyAPI Browser templates use a form with GET-request to change skins
rather than the SELECT’s onchange.Added proper HTTP return code and Accept value for empty requests to
service interfacesFixed POST conversion of dashes to underscores in SOAP requestsNew in 0.6.2Bug 831553 - Better probing for incomming client URI’sQuestion 168374 - Completely rewrite of the SOAPRequestHandler,
fixing a yet unreported bug with arrays and introducing support
for incomming prettyfied XML.New in 0.6.1The major enhancement is support for attachments in the Ladon framework. Read more
about Ladon attachments on: Server attachmentsJSON-WSP Client has built-in support for attachments: Client attachmentsJSON-WSP Client supports Python 3New default skin for the API browserSupport for custom skinningBetter Python 3 support in generalladonctl subcommand “serve” altered to “testserve”Bug fixes: 808331, 821923New in 0.5.1Added cross-version compatible ladon-ctl shell script. This script will have
several sub-commands over time. The first and only command is “serve” to
quickly test one or more service modules.New in 0.5.0Experimental Python 3 supportDropped Cheetah in favor of jinja2 due to lack of Python 3 support in CheetahAdded compat module that handles python 2/3 compatability issues for typesAdded unittests for string integrityNew in 0.4.8Added types to the browser based service navigation interfaceNew in 0.4.7Service Navigation: Better browser navigation for services. New features
are full service documentation with CSS-styled browsable interface.Much more documentationNew in 0.4.6Added export_dict to the dispatcher. Values from this dict will be exported
to ladonized methods if they have **kw at the end of their parameter list.
By default the LadonWSGIApplication will export WSGI’s environ.Much more documentationNew in 0.4.5Moved jsonwspclient.py into the ladon package in subpackage clients:from ladon.clients.jsonwsp import JSONWSPClientNew in 0.4.4Removed old-style method invoking from the jsonwspclient javascript clientAdded a JSON-WSP python client: misc/jsonwsp/jsonwspclient.py. The client
can be integrated into other python modules using the JSONWSPClient class,
but it can also be run as a shell command.New in 0.4.3New feature called mirror/reflection especially designed for asynchronious
client/server communication to keep track on the client which responses
belongs to which requests. For example a request ID can be mirrored by the
server and reflected back to the client, so it is possible to map many
simultaneously incomming responses that are handled by the same function.Ladon documentation for the dispatcherNew in 0.4.2Fixed bug that made incomming booleans always resolve to TrueLadon documentation for collection and typeconverterNew in 0.4.1Added LGPL License.txt in the root of the projectLadon documentation for ladonizeNew in 0.3.7jsonwsp.spec file added to the repository.jsonwsp description specification very near 1.0Bug-fix in wsgi_application.py charset detection moved to the first action
when a request is recieved.Added jsonwsp javascript client that can parse jsonwsp/description objects
and invoke methods on services as function calls.New in 0.3.6jsonrpc interface renamed to jsonwsp, short for JSON Web Service Protocol.
This was decided to prevent confusing whether Ladon’s json-based protocol
supports the json-rpc specified in at:http://json-rpc.org/. Ladon’s json-
based protocol is clearly inspired by json-rpc, but is not the same.jsonwsp response, request and description formats has been altered to contain
‘type’ and ‘version’ values.