MiddleStorm middleware with bottle
Question: How do you use [MiddleStorm](http://pypi.python.org/pypi/middlestorm)
middleware with [bottle](http://bottlepy.org/)? I followed [this
example](http://readthedocs.org/docs/bottle/en/latest/recipes.html), replacing
SessionMiddleware with MiddleStorm, but I can't get it to work.

    
    
    from bottle import *
    from storm.locals import *
    from middlestorm import MiddleStorm
    
    #other bottle code like this here...
    @get('/')
       def index():
       return 'index'
    
    db = create_database("mysql://user:pass@localhost/mydb")
    myapp = MiddleStorm(app, db)
    run(app=myapp, reloader=True, host='0.0.0.0', port=4321)
    

I get this error in console:

    
    
    exceptions.TypeError: __call__() takes exactly 1 argument (3 given)
    

If I change the line with myapp to:

    
    
    myapp = MiddleStorm(app(), db)
    

I get this error on the webpage:

    
    
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/bottle-0.9.5-py2.7.egg/bottle.py", line 651, in _handle
        return callback(**args)
      File "/usr/local/lib/python2.7/dist-packages/bottle-0.9.5-py2.7.egg/bottle.py", line 1143, in wrapper
        rv = callback(*a, **ka)
    TypeError: decorator() takes exactly 1 argument (0 given)
    

edit: bottle, storm, middlestorm are installed

edit2: if I chane myapp line to myapp = MiddleStorm(dafault_app, db) I get
this error:

    
    
    Traceback (most recent call last):
      File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
      File "/usr/local/lib/python2.7/dist-packages/middlestorm-0.8.1-py2.7.egg/middlestorm.py", line 68, in __call__
        return self._app(environ, start_response)
    TypeError: __call__() takes exactly 1 argument (3 given)
    homer - - [17/Jul/2011 16:28:42] "GET / HTTP/1.1" 500 59
    

edit3: with @zeekay code I still get this error:

    
    
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/bottle-0.9.5-py2.7.egg/bottle.py", line 651, in _handle
        return callback(**args)
      File "/usr/local/lib/python2.7/dist-packages/bottle-0.9.5-py2.7.egg/bottle.py", line 1143, in wrapper
        rv = callback(*a, **ka)
    TypeError: decorator() takes exactly 1 argument (0 given)
    


Answer: Actually `default_app` and `app` are synonymous. This should work:

    
    
    myapp = MiddleStorm(app(), db)
    

Just testing briefly and it seems to work for me. Can you try testing this:

    
    
    from bottle import *
    from storm.locals import *
    from middlestorm import MiddleStorm
    
    @get('/')
    def index():
       return 'index'
    
    db = create_database("sqlite://test.db")
    myapp = MiddleStorm(app(), db)
    run(app=myapp, reloader=True, host='0.0.0.0', port=4321)
    

You should be able to drop it in a file and just run.

