[albatross-users] Albatross Form Question

alan.junk at sunwave.com alan.junk at sunwave.com
Fri Apr 2 21:58:20 EST 2004


Hello Everyone,

I've spent the last few days drooling over albatross, reading
documentation and code samples.  It looks like a dream come true the
things I have to program.

Unfortunately, now that I have finally sat down to write my first
albatross application, I'm feeling very lost.  In addition to being new to
albatross, I'm also a python newbie, so I am not sure if I am even
approaching my problem from the right direction.

Let me explain.

Outside of albatross, I currently create customer objects in python and
manipulate them.  For instance:

# create customer object
c = customer(username)

# read firstname of customer
firstname = c.firstName()

# set firstname of customer
c.firstname('bob')

Most of the what the object does is simply manipulate a MySQL backend, but
it also runs some checks.

Inside albatross, I want to create forms (some of them multipaged and
stateful) that will read and manipulate my customer object.

After browsing the albatross docs, I came up with an albatross tag like
this on a form:

First Name: <al-input type="TEXT" name="firstName" expr="c.firstName()">

When I load the form, it shows me an input field with the customer
object's firstName() value inside it.  Good so far.

The part that I'm hung up on is saving form input.  I am able to do it
with something like this:

def page_process(self, ctx):
...
c = customer(username)
c.firstName(ctx.get_value('firstName'))
c.lastName(ctx.get_value('lastName'))
...and so on...

This works but it feels kludgy.  It also seems totally in opposition to
the spirit of albatross.  The bigger my form is the more it bloats my
python code, and if I want to add a field to my form (that will be saved,
anyhow), I have to edit the python script and that feels weird.

Am I approaching this from the wrong direction? Any advice?

Thank you!

Alan







More information about the Albatross-users mailing list