# coding=utf8
"""
A mini-demo of what wsme can do.

To run it::

    python setup.py develop

Then::

    paster serve demo.cfg
"""

from wsme import *
from wsme.wsgi import adapt

import logging


class Person(object):
    id = int
    firstname = unicode
    lastname = unicode


class DemoRoot(WSRoot):
    @expose(int)
    @validate(int, int)
    def multiply(self, a, b):
        return a * b

    @expose(unicode)
    def helloworld(self):
        return u"こんにちは世界 (<- Hello World in Japanese !)"


    @expose(Person)
    def getperson(self):
        p = Person()
        p.id = 12
        p.firstname = u'Ross'
        p.lastname = u'Geler'
        return p

def app_factory(global_config, **local_conf):
    root = DemoRoot()
    
    root.addprotocol('soap',
            tns='http://example.com/demo',
            typenamespace='http://example.com/demo/types',
            baseURL='http://127.0.0.1:8989/',
    )

    root.addprotocol('restjson')

    return adapt(root)

logging.basicConfig(level=logging.DEBUG)

@@ -143,17 +143,40 @@
  import 
-*
+WSRoot, expose, validate
 %0Afrom ws
@@ -520,17 +520,16 @@
 se !)%22%0A%0A
-%0A
     @exp
@@ -682,16 +682,115 @@
 turn p%0A%0A
+    @expose(Person)%0A    @validate(Person)%0A    def setperson(self, person):%0A        return person%0A%0A%0A
 def app_
@@ -849,20 +849,16 @@
 oRoot()%0A
-    
 %0A    roo

Add a setperson function to test complex function arguments