{"action":"created","issue":{"url":"https://api.github.com/repos/dpgaspar/Flask-AppBuilder/issues/135","labels_url":"https://api.github.com/repos/dpgaspar/Flask-AppBuilder/issues/135/labels{/name}","comments_url":"https://api.github.com/repos/dpgaspar/Flask-AppBuilder/issues/135/comments","events_url":"https://api.github.com/repos/dpgaspar/Flask-AppBuilder/issues/135/events","html_url":"https://github.com/dpgaspar/Flask-AppBuilder/issues/135","id":64818715,"number":135,"title":"using request or session in the viewmodel","user":{"login":"reffael","id":10670888,"avatar_url":"https://avatars.githubusercontent.com/u/10670888?v=3","gravatar_id":"","url":"https://api.github.com/users/reffael","html_url":"https://github.com/reffael","followers_url":"https://api.github.com/users/reffael/followers","following_url":"https://api.github.com/users/reffael/following{/other_user}","gists_url":"https://api.github.com/users/reffael/gists{/gist_id}","starred_url":"https://api.github.com/users/reffael/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reffael/subscriptions","organizations_url":"https://api.github.com/users/reffael/orgs","repos_url":"https://api.github.com/users/reffael/repos","events_url":"https://api.github.com/users/reffael/events{/privacy}","received_events_url":"https://api.github.com/users/reffael/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dpgaspar/Flask-AppBuilder/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-03-27T18:02:11Z","updated_at":"2015-03-28T13:21:27Z","closed_at":"2015-03-28T13:21:27Z","body":"I've tried both and I get:\r\nRuntimeError: working outside of request context\r\nerror message\r\nthis is the code:\r\n    \r\n    def get_website():\r\n        if request.args.get('siteID'):\r\n            g.user.siteID = request.args['siteID']\r\n        if hasattr(g.user, 'siteID'):\r\n            return g.user.siteID\r\n        else:\r\n            return False;\r\n\r\n\r\n    class ItemMV(ModelView):\r\n\r\n        datamodel = SQLAInterface(Item)\r\n        list_widget = ItemWidgetList\r\n        list_columns = ['title',  'image','status','link']\r\n        base_filters = [['cid', FilterEqualFunction, get_user],]\r\n        if (get_website()):\r\n            base_filters.append(['siteID', FilterEqualFunction, get_website])"},"comment":{"url":"https://api.github.com/repos/dpgaspar/Flask-AppBuilder/issues/comments/87226905","html_url":"https://github.com/dpgaspar/Flask-AppBuilder/issues/135#issuecomment-87226905","issue_url":"https://api.github.com/repos/dpgaspar/Flask-AppBuilder/issues/135","id":87226905,"user":{"login":"reffael","id":10670888,"avatar_url":"https://avatars.githubusercontent.com/u/10670888?v=3","gravatar_id":"","url":"https://api.github.com/users/reffael","html_url":"https://github.com/reffael","followers_url":"https://api.github.com/users/reffael/followers","following_url":"https://api.github.com/users/reffael/following{/other_user}","gists_url":"https://api.github.com/users/reffael/gists{/gist_id}","starred_url":"https://api.github.com/users/reffael/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reffael/subscriptions","organizations_url":"https://api.github.com/users/reffael/orgs","repos_url":"https://api.github.com/users/reffael/repos","events_url":"https://api.github.com/users/reffael/events{/privacy}","received_events_url":"https://api.github.com/users/reffael/received_events","type":"User","site_admin":false},"created_at":"2015-03-28T13:21:27Z","updated_at":"2015-03-28T13:21:27Z","body":"working like a charm (minor modifications)\r\n\r\n```python\r\n    @expose('/list/')\r\n    @has_access\r\n    def list(self):\r\n        if (get_user() != 1 ):\r\n            self.base_filters.append(['cid', FilterEqualFunction, get_user])\r\n        return super(ItemMV, self).list()\r\n```"}}