How to do basic CRUD apps with Python
James T. Dennis
jadestar at idiom.com
Mon May 14 22:46:38 EDT 2007
Bruno Desthuilliers <bruno.42.desthuilliers at wtf.websiteburo.oops.com> wrote:
> walterbyrd a ?crit :
>> With PHP, libraries, apps, etc. to do basic CRUD are everywhere. Ajax
>> and non-Ajax solutions abound.
>> With Python, finding such library, or apps. seems to be much more
>> difficult to find.
>> I thought django might be a good way, but I can not seem to get an
>> answer on that board.
>> I would like to put together a CRUD grid with editable/deletable/
>> addable fields, click on the headers to sort. Something that would
>> sort-of looks like an online spreadsheet. It would be nice if the
>> fields could be edited in-line, but it's not entirely necessary.
>> Are there any Python libraries to do that sort of thing? Can it be
>> done with django or cherrypy?
> You may want to have a look at turbogears's widgets.
Admittedly I had to look up the meaning of CRUD in this context:
(http://en.wikipedia.org/wiki/Create%2C_read%2C_update_and_delete
create, read, update, and delete).
I'm looking at Turbogears' Widgets in another window as I type
this ... but it will be awhile before I can comment on how they
might apply to the OP's needs. Actually I'm wholly unqualified
to comment on his or her needs ... but I can comment on how I
interpreted the question.
Even with the SQLAlchemy SQLSoup examples there's still an
annoying about of boilerplate coding that has to be done in order
to create a web application for doing CRUD on a database.
The missing element seems to be the ability to autogenerate
web forms and reports with the requisite controls in them.
Imagine, for a moment, being able to do something like:
>>> import sqlalchemy.ext.webcrud as crud
>>> db = crud.open(....)
>>> db.displayTopForm()
'<HTML ....
....
</HTML>'
... and having a default "top level" web page generated with
options to query the database (or some specific table in the
database to be more specific, add new entries, etc).
I'm thinking of some sort of class/module that would generate
various sorts of HTML forms by default, but also allow one to
sub-class each of the form/query types to customize the contents.
It would use introspection on the database columns and constraints
to automatically generate input fields for each of the columns and
even fields for required foreign keys (or links to the CRUD for those
tables?). Ideally it would also automatically hide autogenerated
(index/key) fields, and map the table column IDs to form names (with
gettext support for l10n of those).
I think that's the sort of thing the OP was looking for. Not the
ORM ... the the glue between the web framework and the ORM.
--
Jim Dennis,
Starshine: Signed, Sealed, Delivered
More information about the Python-list
mailing list