On Oct 22, 11:28 am, Omri <omri...@gmail.com> wrote:
> Should I write a very general function that basically exposes the
> database to the client side?

Yes

> Should a write many small functions, each
> wrapping a database call (perhaps sometimes also doing some
> calculations in the background)?

No

> Should I opt to transfer large amounts of data at each JSON-RPC call
> (to minimize server calls),

Yes

> or only ask for the data when needed?

Yes.  Ask only for data when needed, but do as much work in a single
request as you need to do.  Don't use multiple requests when a single
one will do.

> This web-application is intended to be internal to my company, with no
> more than 30 users, and probably no more than 10 simultaneously.

There will be no performance impact at all.  Therefore, you main
consideration should be writing the code in such a way that your own
work is minimized.   Exploit dictionary unpacking to dump JSON data
dictionaries directly to the DB, for example, e.g. (untested)

def insert_json_data(table, jsondata):
    table.insert(**jsondata)

jsondata1 = simplejson.decode(incomingstuff1)
mytable = db.person
insert_json_data(mytable, jsondata1)

jsondata2 = simplejson.decode(incomingstuff1)
mytable = db.account
insert_json_data(mytable, jsondata2)

If you are careful with your field namings between DB and json
packets, you can get a log of mileage out of this. If you put your
table name inside your json data, you can remove even the table arg.









>
> Any thoughts/opinions/discussions are welcome :)
>
> Cheers,
> Omri

Reply via email to