On 16 Aralık, 22:22, Michael Bayer <[EMAIL PROTECTED]> wrote:
> On Dec 15, 11:02 pm, Utku Altinkaya <[EMAIL PROTECTED]> wrote:
>
>
>
> > I do not want to lose invalid values, becouse I want to send them to
> > the user again, so while using object as intermediate holder I have to
> > set attributes invalid values... So "Autoflush = False", and if
> > invalid values are existed the object is reloaded from DB before
> > commit step of web request cycle.
>
> > But while using SQLAlchemy I had the impression that it is not
> > designed to to that, It designers thought objects are direct
> > representation of the data in the database.  I can do this ofcouse
> > some kind of holder class copies attributes from data objects etc, but
> > it is cumbersome, and will force me to write longer code.
>
> > I am expecting someone to tell me the way I am doing is perfectly
> > valid, or another advice
>
> the usual way people handle form validation is using a package like
> FormEncode:  http://formencode.org/Validator.html

OK, I have started implementing widgets to do this, I would do things
like that some place anyway, I will not use data objects for self
validation etc anymore.

>
> i.e. you wouldn't have the invalid data on your ORM object at any
> point. theres nothing "wrong" with how you're doing it, it just has
> disadvantages.  namely, that your ORM objects have to look just like
> your web forms (such as, a web form with three dropdowns, month, day
> and year...

Actullay, I was using mako templates, and setting a context variable
to the model(single thread for a single template instance ofcourse),
and using some of my helper components to write the html, so
converting data to the representable form to the user via html form
had been done there. It was short and simple, I liked it.

> but your ORM object only has "date" on it), and you also
> have to ensure the ORM objects dont get flushed with the invalid data
> (easily breakable).

And looks bad, expriding the object I mean, thanks for the advice.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to