SQLFORM without tables

10 views
Skip to first unread message

Alexandre

unread,
Jan 5, 2010, 5:18:00 PM1/5/10
to web2py
Hi,

I would like to get SQLFORM without tables, just one field on top of the other, is that possible? 

It would be nice if instead of a table, we could iterate through the fields in SQLFORM, so that we could represent it anyway we would like.

Thanks,
Alexandre Rosenfeld

Eng Comp 06 - USP São Carlos
FoG - http://fog.icmc.usp.br
IM Team - AIESEC

mdipierro

unread,
Jan 5, 2010, 5:25:19 PM1/5/10
to web2py-users
I think this should do it:

form=SQLFORM(...)
form.components=[row[1][0] for row in form[0].components]

You can try variations

> FoG -http://fog.icmc.usp.br
> IM Team - AIESEC

Thadeus Burgess

unread,
Jan 5, 2010, 6:13:00 PM1/5/10
to web...@googlegroups.com
I think what he really wants is the same thing I have been discussing
for quite a while :)

For now, sqlform.custom is the way to go

http://web2py.com/AlterEgo/default/show/205

-Thadeus

> --
> You received this message because you are subscribed to the Google Groups "web2py-users" group.
> To post to this group, send email to web...@googlegroups.com.
> To unsubscribe from this group, send email to web2py+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
>
>
>
>

mdipierro

unread,
Jan 5, 2010, 8:18:01 PM1/5/10
to web2py-users
Let me explain one of the problems from decoupling forms from their
HTML representation.

data has different representations depending on its status in the
system. For example in a submitted mime multipart form a file is a
FieldStorage object with a file and a filename attribute. A file in
Python is just an object with read/write methods. A file in the DAL is
just a temporary name into a Field(...'upload') and the data is stored
somewhere else, usually on the filesystem, perhaps in a Field
(...'blob').

A validator is an object that takes the data in a form format and
converts it into DAL format. It fails to convert, it modifies the HTML
form to include error messages.

Think for example of the IS_IMAGE validator. It acts on a FieldStorage
object.

Think also about error messages. Currently they do not have to be
strings. They can be helpers. They can contain links or other
structure.

Validators are two-way filters. Think about IS_DATE. It converts a
date from the string representation choose for the HTML form into
datetime.date format used by the DAL and vice versa when the data is
extracted from the DAL and put into an update form.

Validators since they are filters can be piped.

The all process is designed to take an HTML form, validate it, convert
it, store the data in DAL or return a different form with errors.

Breaking this process in two layers (an abstract form and a form
representation) would require decoupling the role of validation from
the role of converting the data. This is logically complicated. This
may also be practically complicated for the user.

This the reason why so far we have been unable to validate
import_from_csv_file since you cannot use validators for that purpose.

Web2py was designed with the 80-20 rule in mind: make it easy in the
80% of the cases at the expense of making more complex in the 20% of
the cases. You can make things easy for that 20% at the expense of
making things more complex in the other 80% but I do not think that is
what we want.

Anyway, I do think the current system can be improved and made more
general. I do not see how this decoupling can be done. Perhaps it is
just me. I will be happy to see proposals.

Massimo

Jonathan Lundell

unread,
Jan 6, 2010, 7:37:49 PM1/6/10
to web...@googlegroups.com
On Jan 5, 2010, at 3:13 PM, Thadeus Burgess wrote:

I think what he really wants is the same thing I have been discussing
for quite a while :)

For now, sqlform.custom is the way to go

http://web2py.com/AlterEgo/default/show/205

A side note: this page (and I suppose others) refer to what I assume is an svn version:

SQLFORM (starting with rev.726) now keeps the values retrieved from the DB in custom objects that can be referenced by field name and used directly in custom forms without the need to re-access the DB.

...no longer very helpful. A stable release number would be better.

mdipierro

unread,
Jan 6, 2010, 7:39:50 PM1/6/10
to web2py-users
fixed.

Alex Fanjul

unread,
Jan 8, 2010, 11:55:57 AM1/8/10
to web...@googlegroups.com, Thadeus Burgess
This is the most recurrent topic I think. It should be called
"Decoupled, Custom and Tableless Forms". I'd say it would involve lot of
changes for "default" things that web2py does now very well, and that is
the problem.
Alex F

El 06/01/2010 0:13, Thadeus Burgess escribi�:


> I think what he really wants is the same thing I have been discussing
> for quite a while :)
>
> For now, sqlform.custom is the way to go
>
> http://web2py.com/AlterEgo/default/show/205
>
> -Thadeus
>
>
>
>
>
> On Tue, Jan 5, 2010 at 4:25 PM, mdipierro<mdip...@cs.depaul.edu> wrote:
>
>> I think this should do it:
>>
>> form=SQLFORM(...)
>> form.components=[row[1][0] for row in form[0].components]
>>
>> You can try variations
>>
>> On Jan 5, 4:18 pm, Alexandre<airm...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I would like to get SQLFORM without tables, just one field on top of the
>>> other, is that possible?
>>>
>>> It would be nice if instead of a table, we could iterate through the fields
>>> in SQLFORM, so that we could represent it anyway we would like.
>>>
>>> Thanks,
>>> Alexandre Rosenfeld
>>>

>>> Eng Comp 06 - USP S�o Carlos


>>> FoG -http://fog.icmc.usp.br
>>> IM Team - AIESEC
>>>
>> --
>> You received this message because you are subscribed to the Google Groups "web2py-users" group.
>> To post to this group, send email to web...@googlegroups.com.
>> To unsubscribe from this group, send email to web2py+un...@googlegroups.com.
>> For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
>>
>>
>>
>>
>>

--
Alejandro Fanjul Fdez.
alex....@gmail.com
www.mhproject.org

Thadeus Burgess

unread,
Mar 30, 2010, 2:02:03 PM3/30/10
to web...@googlegroups.com
Of course, the decoupling would require an entire re-write of how
validation/forms/filters are written...

See you explain this system that each part relies on another part
working a certain way... when I analyze this through my
programming filter to solve this problem this is what I see...

A class for filtering (parsing html values into python values)
A class for validation (validating already parsed data), this could be
used anywhere within web2py, even import_from_csv_file!
A class for data structure (just the data of a form, like a rows
object, and the types of data)
A class for representation (this will take a data structure, and parse
it into a representable format... like a form, or a table)

Each of these classes could use the others, but they don't rely on the
others.... you could use the filtering without validating the data...
or create a form that can validate, but doesn't represent itself.

-Thadeus

Thadeus Burgess

unread,
Mar 30, 2010, 2:02:22 PM3/30/10
to Alex Fanjul, web...@googlegroups.com
I have about two or three pages in my saved drafts about this subject :)

I just havn't had the time to sit down and figure out a real workable
solution that can integrate into everything else web2py does.

Your right, the defaults are integrated into everything, everything
from default widgets set by the DAL/Fields so that a SQLFORM can
display them.

So the question is, what changes could be made to the DAL to separate
it from data representation.

-Thadeus

Reply all
Reply to author
Forward
0 new messages