Skip to main content

Ralsina.Me — Roberto Alsina's website

Pyjamas and Juno

I am cur­rent­ly in dire need of cre­at­ing a nice ad­min page for a LDAP ad­dress­book, which should do some slight­ly un­usu­al things with the da­ta (like ma­nip­u­lat­ing Post­fix's vir­tu­al table).

So, what the heck, let's al­so learn some­thing new while I'm at it. The vic­tim­s: Py­ja­mas and Juno.

Py­ja­mas is sort of a Python ver­sion of GWT and is blis­s. Fi­nal­ly I can code HTML and JS in python ;-)

And Juno is re­fresh­ing­ly sim­ple. Since the whole fron­tend is done by Py­ja­mas, all I need­ed is a way to route JSON­R­PC calls to python code and op­er­ate in the back­end.

So, here are two use­ful snip­pet­s:

# This decorator decodes JSONRPC arguments as sent by Pyjamas to
# Juno, and calls the target function with the decoded version.
def JSONRemote(target):
    def wrapper(web,*args,**kwargs):
        data = json.loads(postdata)
        id, method, params = data["id"],data["method"],[web,]+data["params"][1]
        return target(*params,**kwargs)
    return wrapper

Us­ing this, any plain juno method works as a JSON­R­PC method!

For ex­am­ple:

def list(web,startwith='*',method=None):
    except ldap.LDAPError, e:
    return resp

See? No JSON de­cod­ing. And no en­cod­ing ei­ther, be­cause I am cre­at­ing the re­sponse us­ing this:

# This class creates a correct JSON response from Juno as required by Pyjamas
class JSONResponse(JunoResponse):
    def __init__(self,result=None,error=None,id=None,code=200):

This is prob­a­bly not a great im­ple­men­ta­tion but it's good enough for me right now.

Translations coming

The span­ish trans­la­tions of most ses­sions of "PyQt by Ex­am­ple" are al­most done, thanks to sev­er­al vol­un­teer­s.

To­mor­row I will up­load at least one.

If any­one wants to trans­late them to oth­er lan­guages, I will be hap­py to in­clude those too.

Grrr... I want one of these. I just need a reason.

I just saw this post about the Shee­vaP­lug. I need one. First I need a rea­son to need it.

  • Back­­up server? Add a USB disk en­­clo­­sure, put ev­ery­thing in a met­al box, in­­stall bac­u­la and-or rdif­f-back­­up?

  • Same hard­ware, Home MPD server?

  • Idem, home SAN?

  • Por­­ta­ble de­­mo server? I could in­­stall some so­lu­­tions on SD cards and show them for clients with this and my net­­book.

Sug­ges­tions ac­cept­ed...

Qt 4.5

Do­ing a rou­tine up­date in my desk­top, I was sur­prised to see Qt 4.5 is now in ex­tra! Way to go Arch!

I had a bad start, because all fonts were broken, but after running fc-­cache -fv as root and my user it looks ok again.

In fac­t, it fix­es a bug that has been an­noy­ing me for a year.

Per­for­mance seems to be snap­pi­er. That may be a bit sub­jec­tive, but things like the an­i­ma­tions in krun­ner now are re­al­ly quick and smooth while be­fore they were jumpy.

And... I can try to make flash work in uRSSus! Yay!

UP­DATE: it just start­ed work­ing:


Contents © 2000-2023 Roberto Alsina