2006/1/13, Jared Kuolt <[EMAIL PROTECTED]>:
>
> Is the DataController meant to be used as CRUD in application, or is
> it meant only for easy data manipulation?
>
> I haven't much time to research right now, but I have a couple columns
> that should be edited by the user, whereas others should be filtered.
> Here's an example:
>
> class Posts(SQLObject):
>     slug = StringCol(alternateID=True, length=255)
>     time = DateTimeCol(default=datetime.now)
>     title = StringCol(length=200)
>     text = StringCol()
>
> The columns slug and time should not be user-edited, but title and
> text should. I was thinking of a syntax like this:
>
> class Posts(SQLObject):
>     slug = StringCol(alternateID=True, length=255, userField=False
>                      filterMethod=my.slugify)
>     time = DateTimeCol(default=datetime.now,
>                        userField=False, filterMethod=my.filter)
>     title = StringCol(length=200)
>     text = StringCol()
>
> The DataController would then be able to build a form simply on the
> title and text only, and run the filters on the form submission. Keep
> in mind that I have barely used DataController and am not up-to-speed
> on the usage. Is there an easier way to do this?
>
> Jared
>

DataController class has property form_fields which is a list with
field names that will be used on the form. So in your case it will be
['title', 'text'].
To calculate column value based on values from other column (i.e. slug
from title), use SQLObject:
http://sqlobject.org/SQLObject.html#overriding-column-attributes

--
Ksenia

Reply via email to