As our application is growing larger, we're noticing some issues with  
coupling and the modularity of apps.

In particular, how plugable are apps supposed to be? It's clear that  
at the top level, a project should be able to access all of its  
parts, but it seems like it should be the case that each individual  
app should be as self-contained as possible, ideally relying only on  
its own code and code supplied by django.

But adding an app to a project isn't as simple as just adding it. In  
addition to adding it to INSTALLED_APPS, you also have to figure out  
if it's self-contained or relies upon other apps. If it's templates  
depend on a context_processor having been called, you have to add  
that to your project's TEMPLATE_CONTEXT_PROCESSORS. Also, an app may  
need to know where it's located in the projects URL space so that it  
can create links to other parts of itself (at least, if you don't  
want a bunch of "../../../lots/of/updirectory.html" kinds of URLs.

So, as I've been thinking about this stuff, I've been wondering if  
some of this could be made less piecemeal and more systematic.

Here are some thoughts, which are pretty raw, but I'd love people's  
feedback.

1. Allow people to set a prefix for each app in the settings.py file.  
This would basically tell the app what URLs that are mapped to it  
start with, and views and templates inside the app could use this  
when they want to create internally mapped URLs. By default, it would  
also pass control of any URL starting with the prefix to the given  
app's urls.py module, much as already happens, I imagine, in most  
people's implementations, but the prefix would be an attribute of the  
app, rather than some unconnected string as it is now.

2. Allow each app to optionally specify a context_processor(request)  
function in their __init__.py file. By default, all the context  
processors that exist would be called in the order that the apps are  
listed in the INSTALLED_APPS attribute. Obviously, this could be  
dangerous because apps could try to define different values in the  
context using the same key. Maybe we could do some kind of fake  
namespacing ( {{ app.key }} to avoid that.

3. Develop some kind of explicit way that apps can declare  
dependencies on other apps so that apps can just be dropped in with  
any dependencies, their prefixes set, and they be good to go.

Or maybe we don't need any of this and I'm just being overly anal  
retentive.

Todd

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" 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-developers
-~----------~----~----~----~------~----~------~--~---

Reply via email to