Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

rpclib-2.5.2 fixes #118

Merged
merged 11 commits into from
Commits on Dec 26, 2011
  1. @plq

    fix csv serializer.

    plq authored
  2. @plq
  3. @plq

    version bump

    plq authored
Commits on Dec 27, 2011
  1. @plq
Commits on Jan 3, 2012
  1. @plq

    support sqlalchemy.Binary

    plq authored
  2. @plq
  3. @plq
Commits on Jan 15, 2012
  1. @plq
  2. @plq

    reverse the tag order in xml schemas so that the child objects in an …

    plq authored
    …inheritance hierarchy show up at bottom
  3. @plq

    changelog update

    plq authored
  4. @plq

    changelog update

    plq authored
This page is out of date. Refresh to see the latest.
View
5 CHANGELOG.rst
@@ -2,6 +2,11 @@
Changelog
=========
+rpclib-2.5.2-beta
+-----------------
+ * Misc. fixes.
+ * Full change log: https://github.com/arskom/rpclib/pull/118
+
rpclib-2.5.1-beta
-----------------
* Switched to magic cookie constants instead of strings in protocol logic.
View
2  src/rpclib/__init__.py
@@ -17,7 +17,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
#
-__version__ = '2.5.1-beta'
+__version__ = '2.5.2-beta'
from rpclib._base import TransportContext
from rpclib._base import EventContext
View
2  src/rpclib/interface/xml_schema/_base.py
@@ -108,7 +108,7 @@ def build_schema_nodes(self, with_schema_location=False):
import_.set('schemaLocation', sl)
# append simpleType and complexType tags
- for node in self.namespaces[pref].types.values():
+ for node in reversed(self.namespaces[pref].types.values()):
schema.append(node)
# append element tags
View
2  src/rpclib/model/_base.py
@@ -257,7 +257,7 @@ class Attributes(ModelBase.Attributes):
values = set()
"""The set of possible values for this type."""
- def __new__(cls, ** kwargs):
+ def __new__(cls, **kwargs):
"""Overriden so that any attempt to instantiate a primitive will return
a customized class instead of an instance.
View
4 src/rpclib/model/primitive.py
@@ -552,5 +552,5 @@ def from_string(cls, string):
class Mandatory(object):
"""Class that contains mandatory variants of primitives."""
- String = String(min_occurs=1, nillable=False, min_len=1)
- Integer = Integer(min_occurs=1, nillable=False)
+ String = String(type_name="mandatory_string", min_occurs=1, nillable=False, min_len=1)
+ Integer = Integer(type_name="mandatory_integer", min_occurs=1, nillable=False)
View
1  src/rpclib/model/table.py
@@ -61,6 +61,7 @@
sqlalchemy.Integer: primitive.Integer,
sqlalchemy.SmallInteger: primitive.Integer,
+ sqlalchemy.Binary: binary.ByteArray,
sqlalchemy.LargeBinary: binary.ByteArray,
sqlalchemy.Boolean: primitive.Boolean,
sqlalchemy.DateTime: primitive.DateTime,
View
1  src/rpclib/protocol/_base.py
@@ -69,6 +69,7 @@ class ProtocolBase(object):
def __init__(self, app=None, validator=None):
self.__app = None
+ self.validator = None
self.set_app(app)
self.event_manager = EventManager(self)
View
55 src/rpclib/protocol/csv/__init__.py
@@ -29,7 +29,9 @@
from rpclib.protocol import ProtocolBase
-def complex_to_csv(cls, values):
+def complex_to_csv(ctx):
+ cls, = ctx.descriptor.out_message._type_info.values()
+
queue = StringIO()
writer = csv.writer(queue, dialect=csv.excel)
@@ -40,16 +42,32 @@ def complex_to_csv(cls, values):
keys = sorted(type_info.keys())
- writer.writerow(keys)
- yield queue.getvalue()
- queue.truncate(0)
-
- if values is not None:
- for v in values:
- d = serializer.to_dict(v)
- writer.writerow([d.get(k, None) for k in keys])
- yield queue.getvalue()
- queue.truncate(0)
+ if ctx.out_error is None and ctx.out_object is None:
+ writer.writerow(['Error in generating the document'])
+ for r in ctx.out_error.to_string_iterable(ctx.out_error):
+ writer.writerow([r])
+
+ yield queue.getvalue()
+ queue.truncate(0)
+
+ elif ctx.out_error is None:
+ writer.writerow(keys)
+ yield queue.getvalue()
+ queue.truncate(0)
+
+ if ctx.out_object[0] is not None:
+ for v in ctx.out_object[0]:
+ d = serializer.to_dict(v)
+ row = [ ]
+ for k in keys:
+ val = d.get(k, None)
+ if val:
+ val=val.encode('utf8')
+ row.append(val)
+
+ writer.writerow(row)
+ yield queue.getvalue()
+ queue.truncate(0)
class OutCsv(ProtocolBase):
mime_type = 'text/csv'
@@ -57,17 +75,16 @@ class OutCsv(ProtocolBase):
def create_in_document(self, ctx):
raise Exception("not supported")
- def serialize(self, ctx):
- result_message_class = ctx.descriptor.out_message
+ def serialize(self, ctx, message):
+ assert message in (self.RESPONSE,)
if ctx.out_object is None:
ctx.out_object = []
- assert len(result_message_class._type_info) == 1, """CSV Serializer
+ assert len(ctx.descriptor.out_message._type_info) == 1, """CSV Serializer
supports functions with exactly one return type:
- %r""" % result_message_class._type_info
-
- # assign raw result to its wrapper, result_message
- out_type, = result_message_class._type_info.itervalues()
+ %r""" % ctx.descriptor.out_message._type_info
- ctx.out_string = complex_to_csv(out_type, ctx.out_object)
+ ctx.out_string = complex_to_csv(ctx)
+ ctx.transport.resp_headers['Content-Disposition'] = (
+ 'attachment; filename=%s.csv;' % ctx.descriptor.name)
View
6 src/rpclib/protocol/http.py
@@ -199,9 +199,13 @@ def deserialize(self, ctx, message):
self.event_manager.fire_event('before_deserialize', ctx)
- if ctx.in_header_doc is not None:
+ if len(ctx.in_header_doc) > 0:
ctx.in_header = self.dict_to_object(ctx.in_header_doc,
ctx.descriptor.in_header)
+ else:
+ ctx.in_header = [None] * len(
+ ctx.descriptor.in_header.get_flat_type_info(
+ ctx.descriptor.in_message))
if ctx.in_body_doc is not None:
ctx.in_object = self.dict_to_object(ctx.in_body_doc,
View
3  src/rpclib/protocol/xml/_base.py
@@ -71,7 +71,8 @@ class XmlObject(ProtocolBase):
conventions.
:param app: The owner application instance.
- :param validator: One of (None, 'soft', 'lxml').
+ :param validator: One of (None, 'soft', 'lxml', 'schema',
+ ProtocolBase.SOFT_VALIDATION, XmlObject.SCHEMA_VALIDATION).
"""
SCHEMA_VALIDATION = type("schema", (object,), {})
View
7 src/rpclib/server/wsgi.py
@@ -42,7 +42,12 @@
def _wsgi_input_to_iterable(http_env):
istream = http_env.get('wsgi.input')
- length = int(http_env.get('CONTENT_LENGTH', str(MAX_CONTENT_LENGTH)))
+ length = http_env.get('CONTENT_LENGTH', str(MAX_CONTENT_LENGTH))
+ if len(length) == 0:
+ length = 0
+ else:
+ length = int(length)
+
if length > MAX_CONTENT_LENGTH:
raise RequestTooLongError()
bytes_read = 0
Something went wrong with that request. Please try again.