Hi Lukasz,
not recommending it, just to answer you: 
On the django side i use a little fumbled version of 
...
#   original code: http://trac.pyworks.org/pyjamas/wiki/DjangoWithPyJamas
#   also from: http://www.pimentech.fr/technologies/outils
...

and on pyjs client side something like

import datetime
from pyjamas.ui.DialogBox import DialogBox
from pyjamas.ui.ScrollPanel import ScrollPanel
from pyjamas.ui.VerticalPanel import VerticalPanel
from pyjamas import Window
from pyjamas.ui.Button import Button
from pyjamas.ui.HTML import HTML
from pyjamas.JSONService import JSONProxy

def flatten_JSON(obj):
    """ Workaround  datetime. only strings, dicts, lists """
    if isinstance(obj, list):
        # Window.alert("list")
        return [flatten_JSON(a) for a in obj]
    if isinstance(obj, dict):
        # Window.alert("dict "+str(obj))
        d = {}
        for key in obj.keys():
            d[key] = flatten_JSON(obj[key])
        return d
    if not isinstance(obj, datetime.datetime):
        # Window.alert("no"+str(obj))
        return obj
    return obj.isoformat()

class RemoteWidgetHandler(object):

    def __init__(self, handler_func, *args, **kwargs): #pylint: 
disable=W0613
        self.action = handler_func
        self._dialog = DialogBox(glass=True)

    def onRemoteResponse(self, response, request_info):
        self.action(response, request_info)
    
    def showError(self, message):
        scroll = ScrollPanel(Size=("1000px", "600px"))
        contents = VerticalPanel(StyleName="Contents",
                                 Spacing=4)
        contents.add(Button("Ok.", getattr(self, "onClose")))
        contents.add(HTML(message))
        scroll.add(contents)
        self._dialog.setWidget(scroll)

        #left = Window.getScrollLeft()
        #top = Window.getScrollTop()
        self._dialog.setPopupPosition(50, 150)
        self._dialog.show()            

    def onClose(self, event): #pylint: disable=W0613
        self._dialog.hide()
        
    def onRemoteError(self, code, errobj, request_info): #pylint: 
disable=W0613
        message = errobj['message']
        if code != 0:
            self.showError(message)
        else:
            code = errobj['code']
            Window.alert("JSONRPC Error %s: %s" % 
                                (code, message))

def remote_call(method, action, *args):
    handler = RemoteWidgetHandler(action)
    nargs = [arg for arg in args]  # kein list copy unter pyjs??
    nargs.append(handler)  # grr: handler argument muss zum schluss stehen
    method(*nargs) #pylint: disable=W0142

class DjangoDokPool(JSONProxy):
    def __init__(self):
        JSONProxy.__init__(self, "/service/dokument/", 
                           ["get_pool_list",
                            "get_pool",
                            "create_pool",
                            "get_preview_list",
                            "delete_dokument"])
        
class DjangoArbeitsPlan(JSONProxy):
    def __init__(self):
        JSONProxy.__init__(self, "/service/arbeitsplan/", 
                           ["get_plan_list",
                            "create_plan",
                            "get_plan",
                            "get_schritte_list",
                            "get_cnc_list",
                            "get_cnc"])
        
CRUD_CALLS = ("create", "read", "update", "delete")

class DjangoModelConnector(JSONProxy):
    def __init__(self, model, connected_calls=CRUD_CALLS):
        call_url = "/service/" + model + "/"
        self.connected_calls = connected_calls
        JSONProxy.__init__(self, call_url, connected_calls)


####

Pls don't close pyjs-users. Maybe any young hero keeps the things up and 
goes further in developing. Would be a dream to have this sexy thing 
(python in a browser) in a bigger audience. IMHO just the critical mass is 
still missing.

Frank


Am Dienstag, 30. Juli 2013 17:40:37 UTC+2 schrieb Maho:
>
> W dniu 27.07.2013 12:44, Łukasz Mach pisze: 
> > Hi, 
> > 
> > Which json-rpc do you recommend for django? 
>
> [...] 
>
> Replying to myself: I recommend rpc4django. 
>
> django-json-rpc has drawbacks as described in prev post, jsonrpc from 
> pyjamas is a bit hard and exotic to install (doesn't work with pip), so 
> haven't tried. 
>
> BTW: fact that nobody replied is a bit scary. Should we countdown users 
> of pyjs/pyjamas? Did we already drop below 10? 
>
>
> -- 
> pozdrawiam 
>
> Łukasz Mach - lukas...@pagema.net <javascript:> 
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"Pyjs.org Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pyjs-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to