so, i am almost sure that i found something buggy or using it bad...
here is what i get :
---8<---
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/ladon-0.7.2-py2.6.egg/ladon/server/wsgi_application.py", line 315, in __call__
self.import_services(self.service_list)
File "/usr/local/lib/python2.6/dist-packages/ladon-0.7.2-py2.6.egg/ladon/server/wsgi_application.py", line 271, in import_services
__import__(service)
File "/var/www/taln/ws/sentokws0.py", line 32, in <module>
class Sentencizer0(object):
File "/var/www/taln/ws/sentokws0.py", line 36, in Sentencizer0
@ladonize(PORTABLE_STRING, rtype = SWS)
File "/usr/local/lib/python2.6/dist-packages/ladon-0.7.2-py2.6.egg/ladon/ladonizer/decorator.py", line 88, in decorator
ladon_method_info = global_service_collection().add_service_method(f,*def_args,**def_kw)
File "/usr/local/lib/python2.6/dist-packages/ladon-0.7.2-py2.6.egg/ladon/ladonizer/collection.py", line 120, in add_service_method
sinfo = self.source_info(src_fname)
File "/usr/local/lib/python2.6/dist-packages/ladon-0.7.2-py2.6.egg/ladon/ladonizer/collection.py", line 79, in source_info
a = ast.parse(src)
File "/usr/lib/python2.6/ast.py", line 37, in parse
return compile(expr, filename, mode, PyCF_ONLY_AST)
File "<unknown>", line 3
^
SyntaxError: invalid syntax
---8<---
with the following (change split \n to character * to be sure that there is not something interfering during soap call with soapui)
@ladonize(PORTABLE_STRING, rtype = SWS)
def sentencize(self, text): """Sentencize...
"""
result = SWS() result.errMessage = '' result.hasError = False result.sentences = []
#
sentences = text.split("*")
subr = []
for sentence in sentences:
S = Sentence()
S.words = sentence.split() subr.append(S) result.sentences = subr
return result
import datetime
a = datetime.datetime.now()
sentencizer = Sentencizer0()
b = datetime.datetime.now()
print("loaded: %s." % (b-a))
def example():
"""..."""
global sentencizer
global R
s = u"""aaa bbb ccc *
dd ee f *
ggg *
hhh i jjj kkk"""
R = sentencizer.sentencize(s)
for s in R.sentences:
for x in s.words:
print x,
print
print R.sentences
so, i am almost sure that i found something buggy or using it bad...
here is what i get :
---8<--- lib/python2. 6/dist- packages/ ladon-0. 7.2-py2. 6.egg/ladon/ server/ wsgi_applicatio n.py", line 315, in __call__ import_ services( self.service_ list) lib/python2. 6/dist- packages/ ladon-0. 7.2-py2. 6.egg/ladon/ server/ wsgi_applicatio n.py", line 271, in import_services _(service) taln/ws/ sentokws0. py", line 32, in <module> object) : taln/ws/ sentokws0. py", line 36, in Sentencizer0 PORTABLE_ STRING, rtype = SWS) lib/python2. 6/dist- packages/ ladon-0. 7.2-py2. 6.egg/ladon/ ladonizer/ decorator. py", line 88, in decorator method_ info = global_ service_ collection( ).add_service_ method( f,*def_ args,** def_kw) lib/python2. 6/dist- packages/ ladon-0. 7.2-py2. 6.egg/ladon/ ladonizer/ collection. py", line 120, in add_service_method info(src_ fname) lib/python2. 6/dist- packages/ ladon-0. 7.2-py2. 6.egg/ladon/ ladonizer/ collection. py", line 79, in source_info python2. 6/ast.py" , line 37, in parse
Traceback (most recent call last):
File "/usr/local/
self.
File "/usr/local/
__import_
File "/var/www/
class Sentencizer0(
File "/var/www/
@ladonize(
File "/usr/local/
ladon_
File "/usr/local/
sinfo = self.source_
File "/usr/local/
a = ast.parse(src)
File "/usr/lib/
return compile(expr, filename, mode, PyCF_ONLY_AST)
File "<unknown>", line 3
^
SyntaxError: invalid syntax
---8<---
with the following (change split \n to character * to be sure that there is not something interfering during soap call with soapui)
---8<---
#!/bin/env python
# -*- coding: utf-8 -*-
# ------- ------- ------- ------- ------- ------- ------- ------- ----
from ladon.ladonizer import ladonize ladontype import LadonType
from ladon.types.
from ladon.compat import PORTABLE_STRING
# ---------- Singleton
class Singleton(type):
cls. _instances[ cls] = super(Singleton, cls).__ call__( *args, **kwargs)
_instances = {}
def __call__(cls, *args, **kwargs):
if cls not in cls._instances:
return cls._instances[cls]
# ---------- for WS result
class Sentence( LadonType) :
words = [ PORTABLE_STRING ]
class SWS(LadonType):
hasError = bool
errMessage = PORTABLE_STRING
sentences = [ Sentence ]
# ---------- WS logic
class Sentencizer0( object) :
__metaclass__ = Singleton
@ladonize( PORTABLE_ STRING, rtype = SWS)
"""Sentencize. ..
result. errMessage = ''
result. hasError = False
result. sentences = []
subr. append( S)
result. sentences = subr
def sentencize(self, text):
"""
result = SWS()
#
sentences = text.split("*")
subr = []
for sentence in sentences:
S = Sentence()
S.words = sentence.split()
return result
import datetime datetime. now() datetime. now()
a = datetime.
sentencizer = Sentencizer0()
b = datetime.
print("loaded: %s." % (b-a))
def example(): sentencize( s)
"""..."""
global sentencizer
global R
s = u"""aaa bbb ccc *
dd ee f *
ggg *
hhh i jjj kkk"""
R = sentencizer.
for s in R.sentences:
for x in s.words:
print x,
print
print R.sentences
---8<---