Login

Tag "controller"

Snippet List

Rails-like MVC Controllers for Django

[See the blog entry](http://sciyoshi.com/blog/2008/nov/18/rails-mvc-controllers-django/) Allows using controllers for views. This allows for nice subclassing to override behavior of views. `Controller.urls` (see below) works fine for subclasses as well. Similar to [snippet #1165](http://www.djangosnippets.org/snippets/1165/) except that it won't break reverse URL resolving and regex validation in URLs. In `views.py`: import mvc class MyController(mvc.Controller): @mvc.view('myview/$', 'myview') def my_view(self): # do something with self.request return HttpResponse('something') class Meta(mvc.Controller.Meta): url_prefix = 'mycontroller-' In `urls.py`: from . import views urlpatterns = patterns('', # ... other urls here ... *views.MyController.urls(r'prefix/') ) Then the view `MyController.my_view` will be accessible from `'prefix/myview/'` and have the name `'mycontroller-myview'`, i.e. `reverse('mycontroller-myview')` will work as expected.

  • rails
  • controller
  • mvc
Read More

Rails Style Controller

Just a quick hack for a Controller style pattern. Similar to the approach taken in django.contrib.admin views things this breaks: 1. {% url %} and reverse() 2. validation provided by regex urlpatterns

  • python
  • controller
  • rubyonrails
Read More

Authenticate against a Windows domain controller

To activate, store this file as `mysite/winauth.py` and use in settings.conf: AUTHENTICATION_BACKENDS = ('mysite.winauth.DomainControllerAuthBackend',) Needs [pywin32 extensions](http://sourceforge.net/projects/pywin32/) installed (and obviously only runs on Windows).

  • authentication
  • domain
  • windows
  • controller
  • pdc
Read More

3 snippets posted so far.