Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

pep8 + custom serializer#1

Closed
gilles wants to merge 1 commit into
pubnub:masterfrom
kwarter:serializer
Closed

pep8 + custom serializer#1
gilles wants to merge 1 commit into
pubnub:masterfrom
kwarter:serializer

Conversation

@gilles

@gilles gilles commented Jun 10, 2013

Copy link
Copy Markdown

Hi,

This pull request contains 2 things:

  • PEP8 formatting.
  • Added the possibility to use a custom serializer for the message. The default one is the same as what is currently in master.

Unfortunately I can't run the unit test. Pubnub retrurns a 400 without other explanation, even when I try on master (and with my keys)

I also have a couple of remarks:

  • Input validation. Some method returns an array [0, 'Missing Channel or Message'], some others raises an Exception. We could have all the input raise a ValueError.
  • The input is a dict, this could be changed into positional arguments:
    • def publish(self, args) => def publish(self, channel, message)

Both of these changes break the API so it should go in a 4.X version

Let me know of you're interested.

Thanks

--Gilles

* PEP8 formating
* Add a custom serializer for the message
@doc-hex

doc-hex commented Jun 16, 2014

Copy link
Copy Markdown

I would 👍 this commit, except I need the deserializer to be replaceable as well. In my case, I am handling money, so I need my JSON numbers to be decimal.Decimal objects. Easily done with a flag to simplejson, but not what everyone needs.

@geremyCohen

Copy link
Copy Markdown

@gilles we've recently pushed an entire re-write of the client lib. Have you had a chance to take a look at it? PEP8 should be handled now, and let us know if you'd be willing to port your customer serializer logic to the new version as well.

@josefdlange

Copy link
Copy Markdown

So, I think I'm digging up some ancient history, but I'm interested in the custom serializer bit here.

I have swept through the latest code and added attributes on the PN classes for a serializer and deserializer callable, using them in place of json.loads and json.dumps respectively (the attributes are set to json.loads and json.dumps in the event that no custom serializer/deserializer has been passed in). I'm at a point where I want to test it meaningfully and haven't quite figured out, well, how to run the tests in this repo. I'm sure it's something obvious but it's 2am and my brain isn't all here.

Anyway, I'd be glad to finish up my version of this change and submit a fresh PR if that would be useful in y'alls eyes.

@geremyCohen

Copy link
Copy Markdown

@josefdlange do you mind emailing support@pubnub.com so we can chat with you more about your use case, so we can research how we could productize this correctly for you (and others)?

qsoftdevelopment pushed a commit that referenced this pull request Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants