Django is handling two pieces of the puzzle, only one of which is SQLObject a
replacement for: database model, and admin UI. In Django presumably the
"human-readable" descriptions are never in the database, so it functionally
behaves like the EnumCol at the db level.

Options for you seem to be a) attaching the db->readable mapping to the column
(there have been a few threads on adding additional attributes to column
objects) and having your UI code look for that data b) manage the mapping
entirely at the UI level (depending how generic you're attempting to be) or c)
switch from an Enum/Choices to a ForeignKey to a lookup table, so the
human-readable values are in the database, and choose a convention that will
allow your UI code to decide that this FK should be shown as a select box and
what field of the FK class to use as "human-readable".

(a) is the closest to the django behaviour, I believe. I haven't looked at all
at whether there's been any work at making their admin UI ORM-layer agnostic
(so adding the right attributes would "just work"? probably not, no foul).
There is a (simpler, lower-level?) DB UI for SQLObject/Turbogears called
Catwalk, but I don't know think it deals with any of these human-readable
alternatives issues. It's not really a problem SQLObject itself is trying to
address.

- Luke



Quoting Jorge Vargas <[EMAIL PROTECTED]>:

> choices
>
> An iterable (e.g., a list or tuple) of 2-tuples to use as choices for
> this field.
>
> If this is given, Django's admin will use a select box instead of the
> standard text field and will limit choices to the choices given.
>
> A choices list looks like this:
>
> YEAR_IN_SCHOOL_CHOICES = (
>     ('FR', 'Freshman'),
>     ('SO', 'Sophomore'),
>     ('JR', 'Junior'),
>     ('SR', 'Senior'),
>     ('GR', 'Graduate'),
> )
>
> The first element in each tuple is the actual value to be stored. The
> second element is the human-readable name for the option.
>
> I was thinking of having an EnumCol in which case it will have no
> "human-readable" value.
>


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to