Re: Model Validation - Best practices

2007-11-15 Thread eriku777

Does anyone know if the Model class validate() method will be ready
any time soon?  I am trying to learn Django but don't want to spend a
lot of time hacking save() work-arounds if new core features will
resolve the issue of business logic validation within models.

-- Eric --

On Oct 24, 12:11 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:

> Right now, there's a validate() method on the Model class, but it is
> incomplete and not recommended for production use.
>
> In the interim, doing things in the save() method is possible, although
> it's not a brilliantly nice design, since save() should never raise
> validation errors and, if it does, you won't get feedback to, say, the
> admin interface or places like that. But it's the workaround you need to
> do at the moment.
>
> Regards,
> Malcolm
>
> --
> Atheism is a non-prophet organization.http://www.pointy-stick.com/blog/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Model Validation - Best practices

2007-11-11 Thread [EMAIL PROTECTED]



On Nov 11, 4:51 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sun, 2007-11-11 at 23:30 +, [EMAIL PROTECTED] wrote:
>
> > > At the moment this is work in progress. There is some development going
> > > on to finish upmodel-awarevalidationand complete some earlier work 
> > > onmodelvalidation. At that time, you'll be able to call
> > > my_model.validate() and have things work similarly to how they do with
> > > newforms.
>
> > are their open bugs or a branch where this work is being done?  I
> > would love to help move this work along or contribute in any way
> > possible to completing model validation.  In my project it is the #1
> > missing feature, requiring quite a few violations of DRY.  I have a
> > large backend set of functionality where I want to use my models and
> > define data validation on the model itself not through the forms.
>
> It's not being done on a branch, since it's very self-contained work.
> Jacob Kaplan-Moss is doing it. He and I and a few other people (Simon
> Willison, Jeremy Dunck, maybe Derek Willis was also there) sat down at
> various points during OSCON back in July and did the design work. Adrian
> poked some hole in some small places during the last sprint (Sep 15).
> Jacob now just needs to find some time to finish it (he's been pretty
> busy with Real Life lately, so let's not flame him).
>
> I realise this is frustrating, but I speak from experience when I say
> that sometimes this stuff can't be easily shared around for simultaneous
> development work. Until the back of the work is broken, multiple people
> would just be tripping over each other and I strongly suspect that would
> be the case here. Anyway, search the django-dev archives for a couple of
> recent threads where this came up and you'll see the latest story.
>
> Regards,
> Malcolm
>
> --
> How many of you believe in telekinesis? Raise my 
> hand...http://www.pointy-stick.com/blog/

Wasn't planning to flame anyone, just looking for a status update as I
had heard some rumors about it being worked on, but couldn't find
anything in trak, and the latest thread I could find on dev was from
2006.  I searched a little harder just now and found the short thread
from last month.  Thanks for the info.  I agree and understand needing
to keep things in a very limited sandbox at the beginning.  As soon as
anything is ready to test/break in this regard I'll be here.

-Tom


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



Re: Model Validation - Best practices

2007-11-11 Thread Malcolm Tredinnick


On Sun, 2007-11-11 at 23:30 +, [EMAIL PROTECTED] wrote:
> 
> >
> > At the moment this is work in progress. There is some development going
> > on to finish upmodel-awarevalidationand complete some earlier work 
> > onmodelvalidation. At that time, you'll be able to call
> > my_model.validate() and have things work similarly to how they do with
> > newforms.
> 
> are their open bugs or a branch where this work is being done?  I
> would love to help move this work along or contribute in any way
> possible to completing model validation.  In my project it is the #1
> missing feature, requiring quite a few violations of DRY.  I have a
> large backend set of functionality where I want to use my models and
> define data validation on the model itself not through the forms.

It's not being done on a branch, since it's very self-contained work.
Jacob Kaplan-Moss is doing it. He and I and a few other people (Simon
Willison, Jeremy Dunck, maybe Derek Willis was also there) sat down at
various points during OSCON back in July and did the design work. Adrian
poked some hole in some small places during the last sprint (Sep 15).
Jacob now just needs to find some time to finish it (he's been pretty
busy with Real Life lately, so let's not flame him).

I realise this is frustrating, but I speak from experience when I say
that sometimes this stuff can't be easily shared around for simultaneous
development work. Until the back of the work is broken, multiple people
would just be tripping over each other and I strongly suspect that would
be the case here. Anyway, search the django-dev archives for a couple of
recent threads where this came up and you'll see the latest story.

Regards,
Malcolm

-- 
How many of you believe in telekinesis? Raise my hand... 
http://www.pointy-stick.com/blog/


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



Re: Model Validation - Best practices

2007-11-11 Thread [EMAIL PROTECTED]


>
> At the moment this is work in progress. There is some development going
> on to finish upmodel-awarevalidationand complete some earlier work 
> onmodelvalidation. At that time, you'll be able to call
> my_model.validate() and have things work similarly to how they do with
> newforms.

are their open bugs or a branch where this work is being done?  I
would love to help move this work along or contribute in any way
possible to completing model validation.  In my project it is the #1
missing feature, requiring quite a few violations of DRY.  I have a
large backend set of functionality where I want to use my models and
define data validation on the model itself not through the forms.


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



Re: Model Validation - Best practices

2007-10-31 Thread Malcolm Tredinnick

On Wed, 2007-10-31 at 18:05 -0700, Ken wrote:
> 
> 
> On Oct 31, 6:07 pm, Ken <[EMAIL PROTECTED]> wrote:
> 
> >
> > I have a similar thing I wish to accomplish.  It's not quite model
> > validation, rather model completion.  The form provides a field that
> > fills one model field but has to be munged to fill a second model
> > field.  I thought the appropriate place is in the model's save()
> > function prior to calling the base class save() function.  Can you
> > show an example of how to access the model's fields?  I tried using
> > self._meta.fields, but I'm apparently indexing it wrong.  models/
> > __init__.py is beyond me. :(
> >
> > I have also wondered why Model.save() returns nothing.  How do you
> > detect if the SQL insert or update fails?
> 
> Duh!  :\ I was making things too complicated.   I was able to redefine
> save() to do what I want.  But, I would still like to hear why save()
> does not confirm if the SQL insert or update succeed or failed?  Or,
> perhaps I've overlooked something in the docs.

It raises an exception. Normal Python error handling process.

Regards,
Malcolm

-- 
If it walks out of your refrigerator, LET IT GO!! 
http://www.pointy-stick.com/blog/


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



Re: Model Validation - Best practices

2007-10-31 Thread Ken



On Oct 31, 6:07 pm, Ken <[EMAIL PROTECTED]> wrote:

>
> I have a similar thing I wish to accomplish.  It's not quite model
> validation, rather model completion.  The form provides a field that
> fills one model field but has to be munged to fill a second model
> field.  I thought the appropriate place is in the model's save()
> function prior to calling the base class save() function.  Can you
> show an example of how to access the model's fields?  I tried using
> self._meta.fields, but I'm apparently indexing it wrong.  models/
> __init__.py is beyond me. :(
>
> I have also wondered why Model.save() returns nothing.  How do you
> detect if the SQL insert or update fails?

Duh!  :\ I was making things too complicated.   I was able to redefine
save() to do what I want.  But, I would still like to hear why save()
does not confirm if the SQL insert or update succeed or failed?  Or,
perhaps I've overlooked something in the docs.

Thanks! Ken


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



Re: Model Validation - Best practices

2007-10-31 Thread Ken



On Oct 24, 12:11 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:

> In the interim, doing things in the save() method is possible, although
> it's not a brilliantly nice design, since save() should never 
> raisevalidationerrors and, if it does, you won't get feedback to, say, the
> admin interface or places like that. But it's the workaround you need to
> do at the moment.
>
> Regards,
> Malcolm
>
> --

I have a similar thing I wish to accomplish.  It's not quite model
validation, rather model completion.  The form provides a field that
fills one model field but has to be munged to fill a second model
field.  I thought the appropriate place is in the model's save()
function prior to calling the base class save() function.  Can you
show an example of how to access the model's fields?  I tried using
self._meta.fields, but I'm apparently indexing it wrong.  models/
__init__.py is beyond me. :(

I have also wondered why Model.save() returns nothing.  How do you
detect if the SQL insert or update fails?


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



Re: Model Validation - Best practices

2007-10-23 Thread Malcolm Tredinnick

On Wed, 2007-10-24 at 04:40 +, Camo wrote:
> Hi Guys,
> 
> I just been working my way through Django, top framework by the way.
> 
> Anyways I just wondering if any one can shed some light model
> validation,
> 
> It seems the only validations are either through the newforms or
> simple validation through the fields.  But there doesn't seem to be
> any bussiness rule validation functions for models.  My concern is
> that validations should really be kept in the model and not in
> forms.
> 
> So I was just wondering how people go about validating models.

At the moment this is work in progress. There is some development going
on to finish up model-aware validation and complete some earlier work on
model validation. At that time, you'll be able to call
my_model.validate() and have things work similarly to how they do with
newforms.

Right now, there's a validate() method on the Model class, but it is
incomplete and not recommended for production use.

In the interim, doing things in the save() method is possible, although
it's not a brilliantly nice design, since save() should never raise
validation errors and, if it does, you won't get feedback to, say, the
admin interface or places like that. But it's the workaround you need to
do at the moment.

Regards,
Malcolm

-- 
Atheism is a non-prophet organization. 
http://www.pointy-stick.com/blog/


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



Re: Model Validation - Best practices

2007-10-23 Thread Kenneth Gonsalves


On 24-Oct-07, at 10:10 AM, Camo wrote:

> So I was just wondering how people go about validating models.

overide the save() method and add your own business rules in the model

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/



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