SV: Choosing the right framework

Carsten Gehling carsten at gehling.dk
Thu Jul 17 04:46:45 EDT 2003


> -----Oprindelig meddelelse-----
> Fra: python-list-admin at python.org
> [mailto:python-list-admin at python.org]På vegne af David McNab
> Sendt: 17. juli 2003 01:32
> Til: python-list at python.org
> Emne: Re: Choosing the right framework

> I've been working on an HTML generation framework called 'pyWeb'. Just
> posted to this ng yesterday, calling for testers.
>
> You might like to visit http://www.freenet.org.nz/python/pyweb and have a
> look.

This I did - to be honest, I'm no real fan of frameworks where you make
objects/functions to represent html-tags. It's IMHO not a good way to
seperate logic and presentation. I'm more to the kind of templates where you
write your own html snippets and embed som sort of template markers inside.

But thanks anyway. :-)

I actually did this myself in PHP, but in a greater level of abstraction. I
needed a fast way of creating "user interfaces" (dialog forms etc.), so I
created a class hierarchy with tab-pages, layout managers, input controls,
etc. that all conformed to the general design.

The complete script for an dialog form to edit eg. an article would look
like this (mind you - it's PHP):
-------------------------------------
$dlg = new UI_TabDialog("Edit article");
$dlg->form_action = "artikel_update.php";
$dlg->add_hidden_field("id", $id);

$page = new UI_TabPage("Article");

$layout = new UI_Layout_row(array(
    array(100),
    array(100),
    array(100),
    array(50, 50),
    array(100)
));

$c = new UI_Control_static("Edit your article and click on "Save");
$layout->add_control($c);

$c = new UI_Control_input("title", "Header", "");
$layout->add_control($c);

$c = new UI_Control_textarea("body", "Main article text", "", 190);
$layout->add_control($c);

$c = new UI_Control_date("releasedate", "Release the article on",
date("Y-m-d"));
$layout->add_control($c);

$c = new UI_Control_date("expiredate", "Expire the article on",
date("Y-m-d"));
$layout->add_control($c);

$c = new UI_Control_image("image_id", "Attach image to article", "");
$c->url_template = IMAGE_UPLOAD_PATH . "image_%d.jpg";
$layout->add_control($c);

$page->add_control($layout);

$dlg->add_page($page);

$dlg->draw();
-------------------------------------

- Carsten






More information about the Python-list mailing list