Hi Clayton,
happy new year to you also!
I reply not inline, because I first need to understand better: it might
be we are not on the same track yet.
==
We should differentiate the following in the discussion:
1. the WAMP serialization format at the wire-level
2. the serializers in WAMP client libraries (and routers)
The WAMP spec currently defines two serialization formats for 1):
* JSON (with an added/optional convention for binary data)
* MsgPack
==
jsonpickle (
https://jsonpickle.github.io/) is a serializer library for
Python that produces _standard_ JSON.
However, the JSON produces will follow certain conventions to add Python
language specific information:
$ python
Python 2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import jsonpickle
>>> class Foo:
... pass
...
>>> f = Foo()
>>> jsonpickle.encode(f)
'{"py/object": "__main__.Foo"}'
Any WAMP router will happily process messages which have stuff
serialized using this serializer in args or kwargs.
Any WAMP client library (supporting JSON) will be able to process such
messages .. it just won't interpret the "magic attributes" like
"py/object" specially.
The question of how to hook jsonpickle into AutobahnPython is totally
specific to AutobahnPython, and this should be possible today.
If you want that, and can't get it working, come back, we'll get it done.
Note: I still don't think it's wise to restrict your choices (language)
by using above, but if you are doing a Python-only app it'll work, and
it should be a developer choice to do so.
==
Serpent (
https://github.com/irmen/Serpent) is both a serialization
format _and_ a serialization library (for Java, .NET, and Python
https://pypi.python.org/pypi/serpent)
The serialization format doesn't seem to be documented, but it is
definitely not JSON, but something "custom":
$ python
Python 2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import serpent
>>> class Foo:
... pass
...
>>> f = Foo()
>>> serpent.dumps(f)
"# serpent utf-8 python2.6\n{'__class__':'Foo'}"
Are you suggesting a WAMP based system should be able to use this custom
serialization format?
a) using this serialization format for the complete WAMP messages: I'
not convinced this makes sense, since the format is totally proprietory
and not even documented. Routers would need to fully implement the
format to do their job.
b) using this seriazation format for args/kwargs only within WAMP
messages (but not for the "surrounding" stuff in WAMP messages): this is
also problematic for different reasons:
- a WAMP router is supposed to be able to transparently translate
between different serialization formats, so clients using different
serialization formats are shielded from this.
- a WAMP router is supposed to ensure anything forwarded strictly
follows the serialization format used to protect innocent client
libraries from being attacked (security). if the router doesn't
understand args/kwargs serialization format, it no longer can provide
that service
- a WAMP router might be configured to do "schema validation" on app
payload (args/kwargs) - this is actually already partially implemented
in Crossbar.io. E.g. you can require the payload of a WAMP procedure
follow a schema, and the router will validate, and deny the forwarding
of a call if the payload doesn't match
==
Cheers,
/Tobias
Am 31.12.2014 um 23:29 schrieb Clayton Daley:
> Obviously, this is your thing... but I always assume that the amount of
> support (financial and volunteer, as well as commercial revenue) for a
> project is roughly proportional to the number of users.
>
> * Telling the large fraction of users -- who are building a single
> language system -- to go somewhere else for ease of use seems
> counter-productive. I figure it actually invites fragmentation by
> encouraging the development/ enhancement of competitive platforms.
> * Your JsonPickle response seems to suggest that the only barrier is a
> serializer... so the rest of the platform (and any future
> improvements) would be shared by the entire community.
>
> > Sure. You can create a custom JSON serializer that is capable of
> serializing Python timedelta. It will need to have *means to
> differentiate normal strings from timedelta strings [empahsis added]*
> for deserialization.
>
> Agreed. Perhaps a generic (at least standard to WAMP) solution to this
> problem would be warranted. My impression is the following (but you
> know your architecture better to criticize):
>
> * I believe Florian and I are really concerned about serializing args
> and kwargs.
> * The current architecture only serializes once... on the complete
> message. Changing the message-level serializer works, but it's
> massive overkill. Every receiver must use that substitute
> serializer... which means that the serializer must exist on every
> supported platform.
> * It would be better to implement a set of (optional) serializer for
> args/kwargs. Recurse through dicts and lists. Skip JSON native
> types. Add some metadata identifying the serializer (None for
> native, string identifying other serialized).
>
> Clayton Daley
>
> On Wed, Dec 31, 2014 at 6:35 AM, Tobias Oberstein
> <
tobias.o...@gmail.com <mailto:
tobias.o...@gmail.com>> wrote:
>
> Hi Clayton,
>
> > I understand how this approach aligns with platform independence. At
>
> the same time,
>
> * If I want to use Autobahn in a single-language environment, it
> should be easy to drop in a serializer that minimizes
> complexity.
> Better for the community if I'm using autobahn for everything I
> write... rather than switching to something that's simpler
> for a
> single-language implementation.
>
>
> If you want language specific, transparent type marshalling (like
> Python serpent) or stuff like transparent object remoting (like
> CORBA or Java RMI), then WAMP probably isn't for you.
>
> WAMP was deliberately designed _not_ following these approaches. We
> like to keep stuff simple and flexible.
>
> * For Python (at least), it might be better to use a "safe"
> serializer
> like serpent (
https://pypi.python.org/pypi/__serpent
> <
https://pypi.python.org/pypi/serpent>). Incidentally,
>
https://github.com/tavendo/__AutobahnPython/blob/master/__autobahn/autobahn/wamp/__serializer.py#L206
>
self.name <
http://self.name> <
http://self.name> = name
>
> class MyComponent(__ApplicationSession):
>
> @inlineCallbacks
> def onJoin(self, details):
> print("session ready")
>
> def printName(obj):
> print(
obj.name <
http://obj.name>
> <
http://obj.name>)
>
> try:
> yield self.register(printName,
> u'com.myapp.printname')
> print("procedure registered")
> except Exception as e:
> print("could not register procedure:
> {0}".format(e))
>
> sleep(1)
>
> try:
> someObj = SomeClass("Oberstet")
> yield self.call(u'com.myapp.__printname',
> someObj)
> print("procedure called")
> except Exception as e:
> print("could not call procedure: {0}".format(e))
>
>
> from autobahn.twisted.wamp import ApplicationRunner
>
> runner = ApplicationRunner(url =
> "ws://localhost:8080/ws1", realm = "realm1")
> runner.run(MyComponent)
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Autobahn" group.
> To unsubscribe from this group and stop receiving emails from
> it, send
> an email to autobahnws+unsubscribe@__
googlegroups.com
> <mailto:
autobahnws%2Bunsu...@googlegroups.com>
> <mailto:
autobahnws+_...@googlegroups.com
> <mailto:
autobahnws%2Bunsu...@googlegroups.com>>.
> <mailto:
autob...@googlegroups.com>
> <mailto:
autobahnws@__
googlegroups.com
> <mailto:
autob...@googlegroups.com>>.
> To view this discussion on the web visit
>
https://groups.google.com/d/__msgid/autobahnws/cc026982-__b503-4003-a907-a57c1a4e6484%__40googlegroups.com
> <
https://groups.google.com/d/msgid/autobahnws/cc026982-b503-4003-a907-a57c1a4e6484%40googlegroups.com>
> <
https://groups.google.com/d/__msgid/autobahnws/cc026982-__b503-4003-a907-a57c1a4e6484%__40googlegroups.com?utm_medium=__email&utm_source=footer
> <
https://groups.google.com/d/msgid/autobahnws/cc026982-b503-4003-a907-a57c1a4e6484%40googlegroups.com?utm_medium=email&utm_source=footer>>.
> For more options, visit
https://groups.google.com/d/__optout
> <
https://groups.google.com/d/optout>.
>
>
> --
> You received this message because you are subscribed to a topic in
> the Google Groups "Autobahn" group.
> To unsubscribe from this topic, visit
>
https://groups.google.com/d/__topic/autobahnws/6Pk0c8JiSn0/__unsubscribe
> <
https://groups.google.com/d/topic/autobahnws/6Pk0c8JiSn0/unsubscribe>.
> To unsubscribe from this group and all its topics, send an email to
> autobahnws+unsubscribe@__
googlegroups.com
> <mailto:
autobahnws%2Bunsu...@googlegroups.com>.
> <mailto:
autob...@googlegroups.com>.
> To view this discussion on the web visit
>
https://groups.google.com/d/__msgid/autobahnws/54A3DF91.__1060804%40gmail.com
> <
https://groups.google.com/d/msgid/autobahnws/54A3DF91.1060804%40gmail.com>.
>
> For more options, visit
https://groups.google.com/d/__optout
> <
https://groups.google.com/d/optout>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Autobahn" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
autobahnws+...@googlegroups.com
> <mailto:
autobahnws+...@googlegroups.com>.
> <mailto:
autob...@googlegroups.com>.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/autobahnws/CACKEAnVCh592WY1Hn07eDkJE7D%3DigXu6jtAJue65WtdBQGp-7w%40mail.gmail.com
> <
https://groups.google.com/d/msgid/autobahnws/CACKEAnVCh592WY1Hn07eDkJE7D%3DigXu6jtAJue65WtdBQGp-7w%40mail.gmail.com?utm_medium=email&utm_source=footer>.