#7442: docs about decoupling urls doesn't decouple all the way
------------------------------------+---------------------------------------
          Reporter:  siva_          |         Owner:  nobody
            Status:  closed         |     Milestone:        
         Component:  Documentation  |       Version:  SVN   
        Resolution:  wontfix        |      Keywords:        
             Stage:  Unreviewed     |     Has_patch:  0     
        Needs_docs:  0              |   Needs_tests:  0     
Needs_better_patch:  0              |  
------------------------------------+---------------------------------------
Comment (by newbie):

 I don't know what people do out in the real world, since I'm still playing
 with the tutorial.  However, the solution I found to this coupling problem
 for the tutorial app is as follows:

 urlpatterns = patterns(__name__.replace('urls','views'),
     (r'^$', 'index'),
     (r'^(?P<poll_id>\d+)/$', 'detail'),
     (r'^(?P<poll_id>\d+)/results/$', 'results'),
     (r'^(?P<poll_id>\d+)/vote/$', 'vote'),
 )

 assuming the string 'urls' doesn't appear in the project name or
 application name, this seems to work.  I guess a regex could be used for a
 more general solution.

 This comes up again when calling reverse() to get the URL for
 HttpResponseRedirect.  My code:

         return HttpResponseRedirect(reverse(__name__ + '.results',
 args=(p.id,)))

 I don't know enough about Python to work around the import line at the top
 of views.py, though.  I guess the solution would be to include the
 application directory in the Python search path, as ubernostrum mentioned,
 in which case there are simpler fixes than those I copied above.  I wonder
 what the security implications of doing this are.

 I'm certainly curious to know how this coupling issue is handled by the
 Django pros

-- 
Ticket URL: <http://code.djangoproject.com/ticket/7442#comment:4>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" 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-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to