Dabo in 30 seconds?

Ed Leafe ed at leafe.com
Sat Jul 30 21:01:20 EDT 2005


On Saturday 30 July 2005 21:16, EP wrote:

> Ed Leafe wrote in response to the "Python vs. Access VBA" thread:
> >  You might want to look at Dabo, which is a database application
> > framework for Python. In about 30 seconds you can create an application
> > that queries a database, displays the results, and allows for
> > editing/updating/inserting/deleting records.
>
> This is a nice pitch.  Can you provide simple, example code that does this?

 It isn't so much a matter of code, but running the AppWizard. You can see a 
description of it at http://dabodev.com/wiki/AppWizard.

> As a non-professional programmer (I write to create my own business tools,
> and for the enjoyment, but no one pays for my code) the ability to generate
> quick db apps like this would constitute a real win, even if the 30 seconds
> is a "Guido 30 seconds" and it takes me 5 minutes (which might
> underestimate Guido by some magnitudes).

 There are additional tools, such as the FieldSpecEditor, that takes the 
generated code and allows you to customize it by setting user-friendly 
captions for field names, hiding/showing various fields in different parts of 
the app, and so forth.

 The wizard isn't the only way to create Dabo apps, but for simple table 
maintenance-type apps, it's certainly the quickest and easiest. Your UI is 
limited by the wizard, though, so if you want something that deviates from 
the standard, you'd best skip the wizard and create it from scratch.

 Dabo UI controls are made to be bound to data. To do this, just set two 
properties: DataSource (the table) and DataField (the field in that table). 
That's it. The framework then takes care of populating the controls with the 
correct values, and propagating any changes you make back to the database.

 You can also set the business rules for your app by editing the 
'bizobj' (business object) scripts. These are generated for you with wizard 
apps. For example, if you have a field named 'zipcode' and you wanted to 
ensure that it was exactly 5 digits long, you edit the 'validateRecord()' 
method of the bizobj as follows:

def validateRecord(self):
 errText = ""
 zip = self.zipcode.strip()
 if len(zip) != 5:
  errText += "Zip Codes must be 5 digits long\n"
 if not zip.isdigit():
   errText += "Zip Codes can olny contain digits\n"
 return errText

 'validateRecord()' is called iteratively on each row of your data set. The 
convention in Dabo business objects is that returning any non-empty value 
will prevent the data from being saved. If you return a string, it will be 
passed back to the UI layer, where it can be displayed to the user. 

 This is a very quick overview of  Dabo. I hope it gives you a basic 
understanding of what the framework offers.

> I suspect there may be others in my shoes, both inside and outside the
> Python community.  If I tell such a person "Oh, you have the choice of many
> database application frameworks in Python" such a person's eyes would glass
> open; if I show them "30 seconds" of clean simple code that does as you
> say, such a framework might not only get more widespread adoption, Python
> could gain wider adoption as well.

 At the PyCon DC 2005, I did such a demo. Originally, I had planned on just 
showing the code behind the framework and explaining our design goals, but as 
the session went on, I felt that the audience wanted to be "wowed", so I ran 
the wizard and created an app that accessed a MySQL database back on the 
server in my home. I have one table that archives email list messages that 
had over 250K records and 1/3 Gig of text, so I entered the appropriate 
values for this table in the wizard, and it completed in just about 30 
seconds (it probably would have been faster if I hadn't been explaining each 
step!). I then ran the generated app, and searched the archive for all 
records containing a certain word. Fortunately, the internet connection was 
good, and it returned the result in less than a second! 

 I spoke with several people afterwards who said that they didn't realize that 
such a tool was available for Python. So while I'm pleased with Dabo's 
technical progress, I'm hoping that its mindshare in the Python world catches 
up soon!
-- 

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com



More information about the Python-list mailing list