#pyramid

/

      • johbo` joined the channel
      • sawdog has quit
      • sawdog joined the channel
      • mejymejy joined the channel
      • kamalgill has quit
      • NotreDev has quit
      • joules has quit
      • brokencycle has quit
      • tiwula has quit
      • supplicant has quit
      • mejymejy has quit
      • supplicant joined the channel
      • nmix has quit
      • _julian__ joined the channel
      • nmix joined the channel
      • nmix has quit
      • vyndion joined the channel
      • vyndion
        inklesspen: why'd you get rid of the def __json__ in the models/__init__.py in mimir?
      • nmix joined the channel
      • inklesspen: nevermind, I didn't see mallows.py when I clicked changes, I guess marshmallow is what's doing the magic
      • inklesspen: though I'm curious why you changed
      • lahwran joined the channel
      • Pumukel has quit
      • johbo` joined the channel
      • inklesspen
        vyndion: hah
      • vyndion
        sorry if I'm too, well, 'up your ass'
      • just wanted to learn more about rpc
      • inklesspen
        vyndion: ok.
      • so
      • you have a writeup
      • and each writeup has many posts
      • digitalsatori joined the channel
      • when you're fetching a writeup, you probably want to include some details about its posts
      • but not the whole thing
      • and certainly nothing about its own children
      • right?
      • vyndion
        yeah, too much
      • inklesspen
        but with a __json__ method, each object can be serialized in only one way
      • johbo` has quit
      • vyndion
        ahhhhhhhhhh
      • inklesspen
        using the mallows.py, when I serialize a Writeup and its children, I can say i want only these certain fields from its children
      • vyndion
        mallows lets you
      • gotcha
      • inklesspen
        but when I serialize a post by itself, i get the whole thing
      • vyndion
        last question, and def more an rpc question
      • def save_writeup(request, writeup):
      • I get request, but where does writeup come from?
      • like is it attached somehow?
      • inklesspen
      • Lcaracol joined the channel
      • it's a view mapper
      • the pyramid_rpc viewmapper takes the rpc args and passes them into the view function
      • (they're also present as a request.rpc_args property)
      • vyndion
        so writeup is an argument supplied to save_writeup
      • inklesspen
        yes
      • vyndion
        maybe I'm asking the wrong thing; the user is saving that writeup. how does it go from the user's browser to the rpc endpoint?
      • like
      • inklesspen
        sure
      • vyndion
        to become an argument
      • inklesspen
        ok.
      • so in the frontend, some component triggers this action: https://github.com/inklesspen/mimir/blob/master...
      • vyndion
        you follow what I'm asking? like the answer could be 'javascript magic'
      • inklesspen
        that calls my javascript jsonrpc client with a method name of 'save_writeup' and a single argument, which in this case is a JS object representing the writeup
      • the jsonrpc client uses that to assemble a jsonrpc request according to the spec (http://www.jsonrpc.org/specification) and makes an ajax POST call to /api, which is the url of my jsonrpc api.
      • now the route predicate which pyramid_rpc installed on that route starts running: https://github.com/Pylons/pyramid_rpc/blob/mast...
      • that route predicate calls setup_request, which looks at the information in the request and determines yes, it is a json-rpc request, for the method 'save_writeup', with args of thus and such.
      • it sets those properties on the request for later, and returns True, which tells pyramid that the request matches this route.
      • pyramid then considers all the view functions installed for this route
      • most of them have a MethodPredicate configured: https://github.com/Pylons/pyramid_rpc/blob/mast...
      • which is true if the request's rpc_method matches the method specified for that view.
      • if it matches, pyramid picks that view as THE view for handling this request.
      • travisfischer has quit
      • then pyramid notices that there's a view mapper configured for the view. (pyramid_rpc installs the mapper which I linked to above by default, but you can override it)
      • the view mapper is responsible for taking whatever view function i've written and converting it to one which matches pyramid's preferred calling convention
      • nmix has quit
      • pyramid wants a view function to take two arguments: context and request
      • but my function takes a request argument and a writeup argument.
      • so the view mapper wraps around it. it basically throws away the context (because that's also present on request as request.context) and then inspects the view's function signature
      • it sees that there is an argument called 'writeup' and one positional argument in the rpc_args
      • so it matches those up
      • and then calls my view function with that argument
      • vyndion
        that argument, writeup, a JS object supplied when you did that ajax POST
      • vyndion queues up 'the circle of life'
      • inklesspen
        yeah.
      • the JS object originates within the frontend react app, but i didn't figure you were asking how that worked out
      • vyndion
        there's this spot where 'novice' knows nothing and 'journeyman' can understand an explanation like you just said
      • inklesspen
        ok
      • vyndion
        but then the 'journeyman' only realizes 'holy shit, am I ever going to have that level of working knowledge'
      • ie, mastery
      • inklesspen
        i didn't really explain route and view predicates
      • but those are discussed in pyramid docs
      • vyndion
        no, I totally understand
      • what you said, and thank you for it
      • just a lot of stuff :)
      • inklesspen
        also the main reason i know how pyramid_rpc works internally is that i made some changes to it
      • to support batched requests
      • vyndion
        think of it like a compliment =]
      • inklesspen
        the code isn't precisely simple, but it's not too complex either
      • vyndion
        jsx looks so splotchy sometimes ><
      • kusut`` joined the channel
      • inklesspen: not necessarily looking for an explanation, but can you point me to the area where react turns the object into writeup? is it https://github.com/inklesspen/mimir/blob/master... which then turns 'value' into it?
      • from frontend actions
      • inklesspen
        writeup is just a positional arg
      • let {'foo': 'bar'} be the JS object
      • rodfersou has quit
      • i call jsonrpc('save_writeup', [{'foo': 'bar'}])
      • which bundles that into a JSON object representing the rpc call: {'jsonrpc': '2.0
      • rodfersou joined the channel
      • kusut`` has quit
      • which bundles that into a JSON object representing the rpc call: {'jsonrpc': '2.0', 'id': 1, 'method': 'save_writeup', 'params': [{'foo': 'bar'}]}
      • vyndion
        gotcha
      • inklesspen
        it only becomes writeup when the viewmapper is matching the positional args against the positional args accepted by my view function
      • kusut`` joined the channel
      • however, I _could_ have passed a JSON object of args instead of a JSON array. that's also legal in the spec: {'jsonrpc': '2.0', 'id': 1, 'method': 'save_writeup', 'params': {'writeup': {'foo': 'bar'}}}
      • in which case the viewmapper would treat it as a keyword arg instead of positional.
      • rickmak_ joined the channel
      • vyndion
        understood
      • there's a bunch of moving parts in mimir, especially with react stuffs, glad I asked
      • inklesspen
        ok, but that's nothing to do with mimir
      • that's just how the jsonrpc spec works
      • jMyles
        raydeo (et al): Is waitress culturally linked to pyramid in some way?
      • vyndion
        I just meant it has a ton of folders and files ^^
      • raydeo
        jMyles: it was implemented by the same guy
      • and part of the pylons project
      • kusut`` has quit
      • jMyles
        that's... (inducing from github) mcdonc?
      • raydeo
        yes
      • jMyles
        I don't know if I've met him or not.
      • rodfersou has quit
      • zepolen joined the channel
      • sontek
        He was at the pycon sprints
      • raydeo
        yeah I'm sure you were in the room with him at some point when showing me hendrix
      • vyndion has quit
      • johbo` joined the channel
      • jMyles
        Gotcha. Yeah I'm sure I met him then.
      • So, what can hendrix offer to be as compelling as waitress to pyramid? (Or gunicorn to django)
      • raydeo
        well waitress only offers compatibility
      • it was built to run on py2/3 windows os x unix... basically everywhere
      • no other wsgi server supported that
      • inklesspen
        jMyles: has hendrix added documentation showing anything other than django yet?
      • inklesspen checks: http://hendrix.readthedocs.org/en/latest/running-hendrix/
      • nope
      • i don't get why you keep coming here to talk about a wsgi server that only works with django
      • jMyles
        inklesspen: The only example that explicitly invokes Django is the quickstart. And yeah, I agree it makes more sense to do more than just Django. Sorry about that.
      • But hendrix runs pyramid wonderfully.
      • zepolen has quit
      • inklesspen
        jMyles: can you point me to a single example on that page where you are not running a django app
      • jMyles
        (better than it does Django for at least some purposes)
      • inklesspen
        it doesn't matter if it runs pyramid wonderfully if the "how to use it" docs only show django
      • raydeo
        pyramid just advocates the wsgi server that is guaranteed to work everywhere for simplicity... we have some deployment docs in our cookbook for other servers