Opened 19 years ago

Closed 18 years ago

Last modified 18 years ago

#416 closed task (wontfix)

Automate site introspection for url pattern modules, view methods, template directories, and applications

Reported by: garthk@… Owned by: Adrian Holovaty
Component: contrib.admin Version: 0.91
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX: no

Description

Read this with your best over-the-top advertising voice:

Are you sick of maintaining module-level URL configuration files? Do you keep forgetting to refer to them in your site-level URL configuration file? Have you recently forgotten to populate TEMPLATE_DIRS or INSTALLED_APPS?

You need AUTOSITE!

AUTOSITE has been brought to you by one programmer's bizarre tendency to spend two hours writing 300+ lines of code to replace around 30 lines of code that were taking him less than two minutes per day to maintain. His
insanity is YOUR gain. If only 100 Django programmers benefit from this module, all his hard work will have been worthwhile.

:)

Attachments (1)

autosite.py (11.5 KB ) - added by garthk 19 years ago.
AUTOSITE! Use it TODAY!

Download all attachments as: .zip

Change History (11)

by garthk, 19 years ago

Attachment: autosite.py added

AUTOSITE! Use it TODAY!

comment:1 by garthk@…, 19 years ago

Okay, more seriously:

There's still a little that can be done to take manual work out of Django programming. If this were any other framework, I'd hardly bother: why save five minutes when the framework is costing you hours of time just to write a simple application? With Django, that application might only be a half hour job and saving five minutes might be significant.

Automatically figuring out which applications are in a site should be a no-brainer. I'm wading through the directory tree rather than looking through the content_types and packages tables, but either way we should be able to save the user the effort. If it's a package under sitename/apps, it's an application, right?

Similarly, there's no point requiring that the user manually tell us where to find the URL configuration file if it's sitting there in plain sight with an obvious name like sitename/urls.py. We're also giving them too much work to do if we insist that they create appname/settings/, appname/settings/urls/, and two __init__.py files just so that the URLs and settings can live in packages rather than modules.

Eliminating the application-level URL configuration file entirely is arguably a step too far, but given the rest of the infrastructure it was pretty easy.

    # Set the URL pattern as an attribute manually... 
    def index(request): 
       # ...
    index.urlpattern = r'^/?$'

    # ... or use a decorator. 
    @urlpattern(r'^/?$')
    def index(request): 
       # ...

Needless to say, whilst I'm going to find autosite.py pretty handy for my own sites I really wrote it for all the people I've seen on #django muttering about the various problems I've solved. Please feel free to use some or all of it for the core framework.

comment:2 by hugo <gb@…>, 19 years ago

Hmm. In my gallery I have two prefixes for URLs - /images/ and /manage/ - that point to two urlpattern configs in the same application (to make use of shortcut notation). So how would I do it with autosite? Will all methods have to have fully qualified urlpatterns - and will the advantage of decoupling app urls from project urls be lost - or will I still have to have a global project-level urlpattern file and all methods of a app will show up under the apps url prefix?

Maybe you should give a full sample on how to use autosite with a project that has two apps with different base urlpatterns, that would make it clearer how autosite is to be used.

comment:3 by Adrian Holovaty, 19 years ago

FYI: As of [415], django-admin.py startapp doesn't create a /apps/appname/urls/ directory, so that's no longer as complex.

comment:4 by anonymous, 19 years ago

out of sight!

comment:5 by Adrian Holovaty, 19 years ago

Resolution: wontfix
Status: newclosed

The new manage.py does some stuff that makes this less complex.

comment:6 by anonymous, 19 years ago

Fun Site to view and learn. Look forward to more.

comment:7 by anonymous, 18 years ago

Component: Core frameworkAdmin interface
milestone: Version 0.92
priority: normallow
Severity: normalminor
Type: defecttask
Version: 0.91

comment:8 by anonymous, 18 years ago

Resolution: wontfix
Severity: minorcritical
Status: closedreopened

comment:9 by Adrian Holovaty, 18 years ago

Resolution: wontfix
Severity: criticalnormal
Status: reopenedclosed

comment:10 by Adrian Holovaty, 18 years ago

milestone: Version 0.92

Milestone Version 0.92 deleted

Note: See TracTickets for help on using tickets.
Back to Top