About the absence of double primary key ...

2007-10-12 Thread Simone Cittadini

I was wondering if the limit on one primary key field only was coming 
out of the "encouraging of clean design" or was just a technical limitation.

I have some classes in my "legacy" app that are uniquely identified by 
two or more attributes, and I was just catching db layer exception when 
the user tried to insert something already there, wrapping them in "user 
error exceptions".

Now when saving I have to search for an equivalent object and in the 
case is found abort the save and throw the error.

Was something I miss in the first method wrong ? Or I miss something 
from django framework which allows me to solve the problem in a more 
elegant way ?


PS: Of course catching / wrapping exception in java is still more lines 
than doing an if/else in python, so maybe the answer is "stop being anal 
about concise code" :)

--~--~-~--~~~---~--~~
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: About the absence of double primary key ...

2007-10-12 Thread Russell Keith-Magee

On 10/12/07, Simone Cittadini <[EMAIL PROTECTED]> wrote:
>
> I was wondering if the limit on one primary key field only was coming
> out of the "encouraging of clean design" or was just a technical limitation.

Search the archives - this has been discussed many times. There is
also a FAQ entry that discussess this limitation:

http://www.djangoproject.com/documentation/faq/#do-django-models-support-multiple-column-primary-keys

The last time this came up on the mailing list, there was some support
for adding support for multiple primary keys - with two conditions:

1) There needs to be a clean, largely unambiguous URL scheme for
addressing objects with multiple primary keys, and

2) Someone needs to write the code

Search the archives if you want more details.

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---