Comment 1 for bug 1115129

Revision history for this message
ctmidi (ctmidi31) wrote :

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)

---8<---

#!/bin/env python
# -*- coding: utf-8 -*-

# ------------------------------------------------------------

from ladon.ladonizer import ladonize
from ladon.types.ladontype import LadonType
from ladon.compat import PORTABLE_STRING

# ---------- Singleton

class Singleton(type):
    _instances = {}
    def __call__(cls, *args, **kwargs):
        if cls not in cls._instances:
            cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
        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)
    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

---8<---