Spyne Unicode フィールドを正規表現で拡張して、有効な電子メール形式であることを確認したいと考えています。しかし、spyne のドキュメントhttp://spyne.io/docs/2.10/manual/03_types.htmlから基本的な例をコピーして貼り付けても、にアクセスすると上記のエラー (タイトルを参照) が発生しますlocalhost/my-url-endpoint?wsdl
。
Django 1.6 と Spyne 2.10.10 を使用しています。Windows8 64 ビットで。失敗する理由はありますか?
コード:
from django.views.decorators.csrf import csrf_exempt
from spyne.protocol.soap import Soap11
from spyne.interface import Wsdl11
from spyne.service import ServiceBase
from spyne.decorator import srpc, rpc
from spyne.model.primitive import Unicode, Integer, Mandatory
from spyne.model.complex import Iterable
from spyne.application import Application
from spyne.server.django import DjangoApplication
class EmailString(Unicode):
__type_name__ = 'EmailString'
class Attributes(Unicode.Attributes):
max_length = 128
pattern = '[^@]+@[^@]+'
class MyService(ServiceBase):
@rpc(EmailString, _returns=Unicode)
def my_function(ctx, my_email):
return "Your email is %s" % my_email
application = Application(
[
MyService
],
tns="http://tempuri.org",
interface=Wsdl11(),
in_protocol=Soap11(validator='lxml'),
out_protocol=Soap11()
)
myServiceApp = csrf_exempt(DjangoApplication(application))
次に、urls.py で MyServiceApp を指定します。
urlpatterns += patterns('',
(r'^my-url-endpoint$', 'myapp.views.myServiceApp'),
)
スタックトレース:
Internal Server Error: /en/wsCRMService
Traceback (most recent call last):
File "C:\Users\Anze\Virtual Environments\my_project\lib\site-packages\django-1.6.1-py2.7.egg\django\core\handlers\base.py", line 101, in get_response
resolver_match = resolver.resolve(request.path_info)
File "C:\Users\Anze\Virtual Environments\my_project\lib\site-packages\django-1.6.1-py2.7.egg\django\core\urlresolvers.py", line 320, in resolve
sub_match = pattern.resolve(new_path)
File "C:\Users\Anze\Virtual Environments\my_project\lib\site-packages\django-1.6.1-py2.7.egg\django\core\urlresolvers.py", line 320, in resolve
sub_match = pattern.resolve(new_path)
File "C:\Users\Anze\Virtual Environments\my_project\lib\site-packages\django-1.6.1-py2.7.egg\django\core\urlresolvers.py", line 320, in resolve
sub_match = pattern.resolve(new_path)
File "C:\Users\Anze\Virtual Environments\my_project\lib\site-packages\django-1.6.1-py2.7.egg\django\core\urlresolvers.py", line 222, in resolve
return ResolverMatch(self.callback, args, kwargs, self.name)
File "C:\Users\Anze\Virtual Environments\my_project\lib\site-packages\django-1.6.1-py2.7.egg\django\core\urlresolvers.py", line 229, in callback
self._callback = get_callable(self._callback_str)
File "C:\Users\Anze\Virtual Environments\my_project\lib\site-packages\django-1.6.1-py2.7.egg\django\utils\functional.py", line 32, in wrapper
result = func(*args)
File "C:\Users\Anze\Virtual Environments\my_project\lib\site-packages\django-1.6.1-py2.7.egg\django\core\urlresolvers.py", line 96, in get_callable
mod = import_module(mod_name)
File "C:\Users\Anze\Virtual Environments\my_project\lib\site-packages\django-1.6.1-py2.7.egg\django\utils\importlib.py", line 40, in import_module
__import__(name)
File "E:\my_project\myapp\views.py", line 146, in <module>
out_protocol=Soap11()
File "C:\Users\Anze\Virtual Environments\my_project\lib\site-packages\spyne\application.py", line 104, in __init__
self.in_protocol.set_app(self)
File "C:\Users\Anze\Virtual Environments\my_project\lib\site-packages\spyne\protocol\xml\_base.py", line 413, in set_app
xml_schema.build_validation_schema()
File "C:\Users\Anze\Virtual Environments\my_project\lib\site-packages\spyne\interface\xml_schema\_base.py", line 189, in build_validation_schema
self.validation_schema = etree.XMLSchema(etree.parse(f))
File "xmlschema.pxi", line 102, in lxml.etree.XMLSchema.__init__ (src\lxml\lxml.etree.c:154067)
XMLSchemaParseError: element decl. '{http://tempuri.org}my_email', attribute 'type': The QName value '{http://www.w3.org/2001/XMLSchema}EmailString' does not resolve to a(n) type definition., line 4
助けてください。