Using Luban with other Python web frameworks

22 views
Skip to first unread message

Nik

unread,
Oct 28, 2009, 10:57:44 AM10/28/09
to luban-users
Hi folks,

I open up the discussion list with the following questions.

1) How can Luban (or parts of it) be integrated in a Python web
framework
like web2py for generating the web UI? What would be a reasonable
ansatz?

2) How does Luban compare (as a "web framework") to other popular
Python frameworks?

3) I didn't have a look at the source code of luban yet. Hence the
question:
Is there some sort of (Python->Javascript) compiler in the core
of luban?

Any feedback is very much appreciated!

Regards
Nik

linjiao

unread,
Oct 28, 2009, 12:05:52 PM10/28/09
to luban-users
Hi Nik,

Luban is not really intended to be another python-based web framework.
Its most important purpose is to answer the following question

Is it possible to have a generic user interface language which is
powerful enough to create sophisticated UI?

I think the answer to that question is close to a yes.

But it is highly possible a web framework could be created by
combining luban with existing tools such as python-based http server
(e.g. cherrypy) and db engines (sqlalchemy etc). The main difference
between luban and existing web frameworks (let me call it WF) is that
to create "views" all WFs encourage users to use a templating engine
that has a syntax that mix html with python commands, while luban
users are using simple python factories. Compared to WFs, luban is
intended only for describing UI itself, and does not integrate a full
suite of database tools as WFs do (you can use any sort of db engines
with luban, however).

About using luban with existing WFs, there might be several different
ways. One possibility is that you just use the part of luban that
translate abstract UI descriptions to javascript. In luban, a UI is a
hierarchy of python objects, and that hierarchy is converted to a json
dictionary. The luban javascript library then takes that json
dictionary and creates javascript UI widgets. So what you could do is
just use that part of luban: luban.weaver.web and luban.weaver.web/
javascripts

Hope I sort of answer your questions.

--Jiao

nitralime

unread,
Oct 28, 2009, 1:48:25 PM10/28/09
to luban...@googlegroups.com
It would be very nice if you could give me more details
about the architecture of luban regarding the process of
UI generation and eventually a module dependency graph.

A quick check of some files under luban.weaver.web etc. shows
that at least some subpackages of prye are needed.

Regards
Nik

linjiao

unread,
Oct 29, 2009, 10:25:43 AM10/29/09
to luban-users
Hi Nik,

The architecture of luban can be described in two words: visitor
pattern. For the web rendering part, a ui representation hierarchy
(let me call it ui tree) is converted to a python dictionary by
luban.weaver.Content2Dict, which is a visitor of the ui tree. This
python dictionary is json compatible and is converted to a json
dictionary to be handled by luban javascript library. Luban js lib has
a "documentmill", which is also "visitor"-like (see javascripts/luban/
luban-documentmill.js) and converts that json dictionary to javascript
calls to create html elements.

So at the minimum what you could just use the class
luban.weaver.Content2Dict on the python side, and then you can use the
luban javascript library. You might want the ui element representation
classes in luban.content too, which depends on the pyre descriptor
classes (pyre.inventory). But you could create and use you own ui
element classes as well since the Content2Dict is quite generic.

If you don't have time to do extensive rewrites, the luban core
depends on "journal" and "pyre", both are pyre packages.

--Jiao

linjiao

unread,
Oct 29, 2009, 1:51:34 PM10/29/09
to luban-users
Hi Nik,

I think about this a bit more. To use luban with other web frameworks
without doing much rewriting, you will need

python packages (pure python part is enough)
pyre, journal, opal (all inside pyre): svn://danse.us/pyre/branches/patches-from-jiao
luban: svn://danse.us/pyregui/releases/luban-0.2a2/luban

javascripts:
svn://danse.us/pyregui/releases/luban-0.2a2/luban/weaver/web/javascripts

Thanks!
--Jiao

Nik

unread,
Nov 1, 2009, 2:22:20 PM11/1/09
to luban-users
I had a look at it at weekend.
Factoring out the UI generating code cleanly
and building a slim Python package is not
a straightforward task!! There is a very
large interdependency in place!!

Regards
Nik
Reply all
Reply to author
Forward
0 new messages