mrjoes/flask-admin — pull request #73 by techniq (2012-09-24 16:26:40+00:00)
Title: Add request-scoped extra_template_args to BaseView

Add request-scoped extra_template_args to BaseView to allow subclasses of BaseView/ModelView to add extra context to templates.

This is something I've been using in my own subclass of ModelView to keep from having to copy the entire view code of a view (for example, edit_view) to add something to my custom templates (I can just call super)

A simplified example:
```python
@expose('/edit/', methods=('GET', 'POST'))
def edit_view(self):
self.extra_template_args['model_name'] = self._prettify_name(self.model.__name__)
self.extra_template_args['can_view'] = self.can_view
self.extra_template_args['view_url'] = url_for('.view_view', id=id)
return super(BaseModelView, self).edit_view()
```

The before_request code feels a little ugly, but it was the best way I could find to set a request-scoped variable (I think I tried to use the provided flask.g but ran into an issue, but maybe it's still possible to go that route to save on changes/hooks).

I wasn't sure the best way to document this in Sphinx to show the available property.