Hi folks!

I'm creating an application to manage an art show (with art pieces to view 
and sell, silent and voice auctions, and a sales process). To have this 
work, it of course needs to keep track of people (including names, 
addresses, email, etc). But to make this more useful to anyone, I want to 
include the ability to replace the included "Person" model with another, 
should the implementor so choose.

What I've done so far is to split the Person model into another app (called 
Peeps) and removed all but a few necessary linkages between the Artshow and 
Peeps app. It was reasonably simple, but a few things seem "dirty" so I'm 
wondering if anyone else has a more experienced or authoritative suggestion 
for this.

I'll detail the points below, but if anyone wants to look at the code, 
please visit my github 
at https://github.com/chmarr/artshow-jockey/tree/peeps  (the "peeps" branch 
has the progressive changes on it).

Details:


   - I'm supplying the code as a combination of a project and two apps, 
   both to make it easier for a "quick start", and to put more of the 
   information that is not immediately related to either the Artshow or Peeps 
   app at the project level.
   


   - I've created a settings called ARTSHOW_PERSON_CLASS which is currently 
   set to "peeps.person"
   - I should probably rename it to ARTSHOW_PERSON_MODEL ??
      - there doesn't seem to be a clean way of turning a text string into 
      a reference to the Model class. I've extracted a line from the django 
core 
      code:
   

from django.db.models.loading import get_model
> from django.conf import settings
> model = get_model ( *settings.ARTSHOW_PERSON_CLASS.split('.',1) )


But there's no official django function to do this. Given this usage, 
perhaps we should ask this to be exposed for 1.5 ??


   - The Artshow app needs the app to have the following attributes: name, 
   email, reg_id, comment, mailing_label(as function).
   - Is there a better method of supporting a replaceable model? Eg: using 
      ARTSHOW_PERSON_CLASS pointing to some kind of proxy class that will map 
the 
      Artshow app requirements to what the Person model can provide?
      - Can this be done in a way to avoid name clashes in the attributes? 
      For example, I have used a single field called "name", while many contact 
      managers might use first and last name, and use "name" for some other 
      purpose.
      - In which app would this linkage code reside? Since its the binding 
      between two otherwise unrelated apps, it seems appropriate to put that at 
      the _project_ level, rather than app. That make sense?
   


   - When selecting a person, I'm using the ajax_select app, which seems to 
   be able to be easily changed if I replace the Person model. ajax_select 
   requires a little code to make this work. As per the above question, 
   where's the best place to have this reside?
   

Thanks for any comments!  If there's already some info out there, or a 
sample project that does this "replaceable model" thing well, I'd 
appreciate a reference. If there isn't such a thing, I'm more than happy to 
create a "HowTo" with all the information I can put together.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/B9DRmowtZ9sJ.
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