Download - All IT eBooks

Transcript
Chapter 9
Our updated urlpatterns
Our urlpatterns, for the example AHAH solution above and for the fuller
client-side database example solution below, are as follows:
urlpatterns = patterns(u'',
(ur'^$', directory.views.homepage),
(ur'^accounts/login/$', u'django.contrib.auth.views.login'),
(ur'^admin/', include(admin.site.urls)),
(ur'^ajax/check_login', directory.views.ajax_check_login),
(ur'^ajax/delete', directory.views.ajax_delete),
(ur'^ajax/download/(Email|Entity|Phone|Status|Tag|URL)',
directory.views.ajax_download_model),
(ur'^ajax/login', directory.views.ajax_login_request),
(ur'^ajax/new/Entity', directory.views.new_Entity),
(ur'^ajax/profile/(\d+)', directory.views.ajax_profile),
(ur'^ajax/saveimage/(\d+)', directory.views.saveimage),
(ur'^ajax/save', directory.views.save),
(ur'^ajax/search', directory.views.ajax_search),
(ur'^(create/Entity)', directory.views.redirect),
(ur'^(create/Location)', directory.views.redirect),
(ur'^manage/Entity/?(\d*)', directory.views.modelform_Entity),
(ur'^manage/Location/?(\d*)',
directory.views.modelform_Location),
(ur'^profile/images/(\d+)', directory.views.image),
(ur'^profile/(new)$', directory.views.profile_new),
(ur'^profile/(\d+)$', directory.views.profile_existing),
)
And that is the last of the code we need!
We now have, on the server-side and client-side, all the pieces in place for a complete
system that includes some best practices. We can tinker and extend it, but we have
a complete working system now.
Summary
We have now covered all the bases for a simple, AHAH solution, and most of
the time this will be best. However, there is more that we can do. In general, lazy
programming and lazy network access that pulls as little as possible and does so as
late as possible is the solution of choice and works better than a premature proactive
solution that seems to be the root of all evil.
In our next chapter we will cover further customization and development. Let's go!
[ 241 ]