Hi,
I'm developing a web hosting control panel and I've decided to split
it into several reusable applications:

(a) One subset of this reusable applications are those which implement
the typical services of an ISP, such as:
dns, web, mailing lists, databases, vps, and so on...

(b) Then there are a bunch of reusable applications that provide
different functionalities to these service applications, e.g:
*contacts: once this app is installed each new service will be
forced to have one contact asociated with it.
*daemons: once a service is saved/deleted (e-g. new email account
it will trigger the selected script that performs whichever change is
necessary on the ISP servers...
*billing, *payment.. and so on..

So in order to make it as much reusable as posible I've been playing
with the "dynamic mixin pattern". I've implemented it in two steps:

1) The list of models that implement the different services
(apps of type (a)) should be provided on the settings.py file, like:

SERVICE_MODELS = (
   'django.contrib.auth.models.User',
   'dns.models.Name', 'dns.models.Zone',
   'web.models.SystemGroup', 'web.models.VirtualHost',
   'mail.models.VirtualAliase',
   'lists.models.List',
   'vps.models.VPS',
   'jobs.models.Job',
   'databases.models.Database', 'databases.models.User',
)

2) Then for each model listed on this list, each application of type (b)
will provide their functionality by means of dynamic mixin; for example:
contacts app will dynamically add ServiceModelMixin to the bases of
each listed model, as well as adding a ServiceAdminMixin class to
the bases of each related ModelAdmin class.

It is clear what I mean?

As far as I know this kind of dynamic patterns: changing classes at
runtime and this kind of stuff, are not very well seen on Django and
python communites. So despite of working for me, it really leaves me
with unsettling feelings, like as something should be wrong with
this solution. But honestly I don't know any other approach that provides
the same degree of reusablility than this: third party apps will be
capable of being services just by putting their models on SERVICE_MODELS
(actually I've already done that with django.contrib.auth), also seems
that my apps can be more easily reused on other projects.

So what is your opinion on this? It's an evil pattern? What approach
will you use? Would you make the Mixin explicit on each class
declaration? something else?

Thanks !!
-- 
Marc

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to