Skip to content

Instantly share code, notes, and snippets.

View FelixSchwarz's full-sized avatar

Felix Schwarz FelixSchwarz

View GitHub Profile
@FelixSchwarz
FelixSchwarz / foo.c
Last active January 29, 2021 09:02
meson dummy with two source files
int increment(int x) {
return x+1;
}
@FelixSchwarz
FelixSchwarz / xml-movie-model.py
Created December 31, 2013 14:03
example implementation to serialize a given model to xml: https://mail.python.org/pipermail/python-de/2013q4/003488.html
from lxml import etree
from soapbox import xsd
class Actor(xsd.ComplexType):
name = xsd.Element(xsd.String)
role = xsd.Element(xsd.String)
class Actors(xsd.ComplexType):
actor = xsd.Element(Actor)
from spyne.application import Application
from spyne.decorator import rpc
from spyne.model import Unicode
from spyne.protocol.soap.soap11 import Soap11
from spyne.service import ServiceBase
class Customer(Unicode):
class Attributes(Unicode.Attributes):
min_len=1
@FelixSchwarz
FelixSchwarz / gist:6507982
Last active December 22, 2015 17:39
sample for https://github.com/arskom/spyne/issues/272 ("Unicode.customize(min_len=6) throws exception")
from spyne.application import Application
from spyne.decorator import rpc
from spyne.model import ComplexModel, Unicode, Boolean
from spyne.protocol.soap.soap11 import Soap11
from spyne.service import ServiceBase
import logging
logging.basicConfig(level=logging.WARN)
def validate_python(self, value, state):
import logging
log = logging.getLogger(__name__)
log.info('URIValidator: %r' % value)
try:
splitted_url = urlsplit(value)
except:
self.raise_error_bad_url(value, state)
scheme = splitted_url[0] # '.scheme' in Python 2.5+
netloc = splitted_url[1] # '.netloc' in Python 2.5+