Hi Malcolm and others,

Malcolm Tredinnick schrieb:
> On Wed, 2009-08-12 at 11:39 +0200, Thomas Guettler wrote:
>> Hi,
>>
>> I am writing a workflow engine. The base workflow is stored in the DB.
>> But some code needs to written for most workflows.
>>
>> This means I need code for a model instance (and not code per mode class).
>>
>> To make this most pythonic, how could this be done?
>>
>> My idea: since I want the workflow to be portable to several installations, 
>> I don't use
>> serial IDs for primary keys, but slug-fields. The slug-field could be a 
>> importable
>> classname like 'foo.workflow.MyClass'.
> 
> You already have the content type table for referring to other model
> objects. Why not use that so that you can maintain some referential
> integrity?

Content Types use serial keys. Take something like a ticket system:
Serial keys are good for the tickets. But if you have something like a
TicketTypeModel it is not a good solution. The customer uses the live
system and can create new TicketTypes. But during the same time,
I might create new TicketTypes in my development system. The serial IDs clash.

And the TicketTypes or (Workflow-Models) need to be installable for several 
customers.

>> Now I want that the Workflow model instance inherits from MyClass. This must
>> be done at runtime. I think this could be done with a custom manager.
> 
> This is where I become Old Conservative Malcolm and say that you might
> want to consider NOT abusing model inheritance! :) I have reasons,
> though, so let me explain...

... thank you for this hint. Up to now, I don't need model inheritance
at runtime. The model instance would inherit from a normal python class.
I even did not think about it. But you did and that's good.
I drop my first idea, because I understand, that doing model inheritance at
runtime does smell bad.

> 
> I try to always relate this back to Python and what you can do in Python
> with normal classes (Django's ORM just provides a way to store parts of
> classes on disk). You can     do what you want in Python, using the type()
> command where you can create whatever base classes you like. 
....
Yes, I have your opinion, too.

  Thomas Güttler

-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to