1
1

Though not documented, OSQA modules provide a rather flexible plug-in architecture for the application. OSQA modules can supplement the app’s URL structure, and provide additional startup code, views, templates, database models, and user authentication providers.

To provide even greater flexibility, I would like to suggest that OSQA provide the facility for modules to contain Django middleware classes. OSQA could implement its own ModuleMiddleware class, for example, which would find and delegate to any middleware.py files detected in OSQA modules.

The main use case I would have for this facility would be supporting automatic user logins based on the session cookie of another application running on the same domain, and for which I have already written an OSQA authentication module.

asked 01 Dec '10, 23:16

Kevin%20Yank's gravatar image

Kevin Yank
436111824
accept rate: 28%

edited 29 Mar '11, 18:28

Would you be willing to post that code? I'm working on the same thing, and that would shortcut a bunch of development. Thanks!

(29 Mar '11, 17:36) JonathanB

Post what code, specifically, @JonathanB?

(29 Mar '11, 18:29) Kevin Yank

The code on trunk already does what you're looking for, just add a variable named MIDDLEWARE_CLASSES on the __init__.py file of the module, containing a list of your middleware, the only difference is that the path used should be relative to your module. So if you have mymodule, and a file named middleware.py, and inside a piece of middleware named MyMiddleware, the module __init__.py would contain the following:

MIDDLEWARE_CLASSES = [
    'middleware.MyMiddleware',
]
link

answered 29 Mar '11, 17:58

Hernani%20Cerqueira's gravatar image

Hernani Cerq... ♦♦
16.8k65975
accept rate: 52%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×144
×32
×24
×6
×5

Asked: 01 Dec '10, 23:16

Seen: 572 times

Last updated: 29 Mar '11, 18:29

powered by OSQA