Saturday, April 14, 2012

Re: Where do ya'll put your glue models?

I wouldn't think of my models as "glue". I would write down a list of
requirements and call that an app. It obviously won't need to include
Poll and Article because they exist already and can be imported untouched.

Most of the Django books and docs suggest that you segregate
functionality into separate apps as much as you reasonably can. Python
lets you import stuff very easily. And once you get a sizeable
application you would be refactoring it anyway into still more separate
apps just to keep things simple.

I avoid forking unless I am prepared to maintain an app myself forever.

My 2c

Mike


On 15/04/2012 1:04am, Hanne Moa wrote:
> Say that there's an excellent 3rd party app "articles" with a model
> Article and another most excellent 3rd party app "polls" with a model
> Poll. How do you glue them together?
>
> If an Article may have several Polls and a Poll may be used in several
> Articles, you can glue them together with a new model with a foreign
> key to each of Poll and Article. But where do you place these glue
> models? Some possibilities are:
>
> 1. monkey patch or fork one or both of the 3rd party apps. Then you
> have a problem when there's a new upstream version of the
> patched/forked app.
> 2. make an app "articlepoll" to hold the ArticlePoll model. This app
> can then be reused by other projects, but you might wind up with
> zillions of them.
> 3. make an app "glue" for ArticlePoll and any other glue models you
> need. This app is then 100% project-dependent.
> 4. treat the project as an app and add the glue models there.
> ...
> last. a combination of the above.
>
> What other possibilities are there? What is best practice?
>
> I'm refactoring and upgrading a project that is very fond of option 1
> at the mo' and there *must* be a better way.
>
>
> HM
>

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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate