I use PostgreSQL exclusively too, and rely on tons of constraints
within the db - from unique indexes built through functions, to actual
functions themselves.

I still, pretty much, always query the db to check for a duplicate
value or possible constraint violation.
1- It's easier than parsing errors.  plus you don't have to
continually flush() or save() to trap the error.
2- There's really not much of a performance hit on any site i've ever
worked on.

In terms of the MVC debate - I've gone through the entire array of
options that Mike Orr has illustrated ( though not all in Pylons ).
I've had Models that have most of the logic, and the Controllers just
call them... I've had Models that have no logic... and I've had Models
that wrap ORMs as an abstraction layer, so I can use multiple backends
(or ORMs ) easily.

After years of struggle, I've ended up with this approach:
- I put 'search' and 'new' functions in the model.  I also put
'render' functions too ( like model.F_url() to display a url )
- If more than one controller needs to do similar operations on the
model, I break it out into a helper method and stash it as a library
function.

The problem I encountered with putting too much logic in the models,
is that MANY of my models were highly interrelated with other models.
>From a maintenance and testing standpoint, this created too many
headaches.  I really don't like 'horizontal' interactions of models
creating and modifying one another.  So many issues arose.  Examples
that caused issues for me were Group creates / controls Members ( and
vice versa );  or if Account creates AccountAsset or ApiKey.

I can't recall if I had the most issues with Python or Perl or
something else... but with horizontal interaction within the model, I
always had issues of inclusion order / dependencies / etc.

So I've found it simpler that each Model is only concerned with a
representation of One member of its own class -- and that a
Controller , or helper function , handles the interrelation of all of
them.

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

Reply via email to