[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnumed-devel] web client via pyjamas

From: lkcl
Subject: Re: [Gnumed-devel] web client via pyjamas
Date: Fri, 9 Jul 2010 14:34:42 -0700 (PDT)

Gour-4 wrote:
> Sebastian> I guess it would be a lot of work to start by repacing the
> Sebastian> whole GNUmed GUI in one go but you could attempt to make a
> Sebastian> plugin run by porting as much as needed.
> I agree.

this is what i have been commissioned to do with fontforge.  one dialog box
at a time, starting with the most useful one (kerning metrics).  you can
continue using the fontforge GUI, and you can also fire up the JSONRPC
service and use the (fledgling) pyjamas demo apps as well, to get at the
exact same data.

Gour-4 wrote:
> Sebastian> browser. So from my limited knowledge I would say that one
> Sebastian> has to write some more bridging code to feed any data from
> Sebastian> the database to the browser.
> FAQ says/recommends to use e.g. Django for Models - Django has nice &
> very useful utility to inspect legacy database and import into its ORM.

 django is something i personally recommend purely because of its ORM and
the fact that django "south" is an ORM management / migration tool.  no more
"alter table" statements: just... edit the python model code, save it, and
run ./manage startmigration {options} voila, transition is done, data is
preserved etc.

 i just _love_ that, having done some pretty awful things to sql databases
in the past :)

 if you have an existing database, with existing python code which accesses
that database, i DO NOT recommend that you use ANY web framework AT ALL, if
you are going to convert the front-end to pyjamas.  any server-side web
framework will simply get in the way.

what i recommend instead is which is based on, which is part of the standard python distribution
(but is not).

as both SimpleXMLRPCServer and SimpleJSONRPCServer are based on
SimpleCGIServer, which is based on SimpleHTTPServer, you have the simplicity

a) doing everything from python.  no apache web server needed

b) not having any complex or unnecessary dependencies: django is _huge_ and
the only bits of it you're going to really use is... its ORM!

c) you _will_ still need, for uploading of files, to accept HTTP POST of
multi-part forms.  but - surprise-surprise, this is covered by

d) for the pyjs version, you will still need (once and only once) to load
the statically-compiled HTML+javascript of the application. 
surprise-surprise, this is covered by SimpleHTTPServer.

so there's absolutely no need for any web server like apache, or in fact any
web server framework at all: all you're doing is GET of static files, POST
of multi-part forms and JSONRPC.  _nothing_ else.  no HTML templates -

the whole approach really _is_ turning browsers and browser engines into
desktop frameworks, escaping from all the god-awful nastiness of that
latest-and-greatest "spiffy javascript framework" by just... entirely
bypassing it all.

lastly it's worth reiterating that i strongly advise you not to tackle two
tasks at once: write a wrapper which takes psycopg return results and
returns lists of dictionaries with strings, ints, floats and None in (dates
aren't supported in json but you can do "class hints" so could conceivably
write a date "class"...) then return that munged data from a jsonrpc call.

job's done: you've converted (boringly) the entire GNUmed middleware into a
JSONRPC service, which you can even write unit tests for (as previously
mentioned, lovelyjsonrpc or jsonrpclib.tgz).

what's neat about writing unit tests is that _later_ you can convert away
from psycopg and use sqlalchemy, sqlobject or even django's ORM (because of
the features offered by django south i seriously strongly recommend it).

and the conversion to django ORM (or whatever) can be done one function at a
time, not even impacting day-to-day use of the whole application.  you can
keep psycopg "direct" access as well as converting line-by-line to django
(or whatever).

View this message in context:
Sent from the GnuMed - Dev mailing list archive at

reply via email to

[Prev in Thread] Current Thread [Next in Thread]