Repository: bokeh/bokeh

Issue:
app examples broken on Windows on master 
All apps are not working properly on windows. Sliders and Stocks are not raising any error (neither on server or js client side, ad all PUT requests are successful (200)) but are not working properly (only selection functionality on stocks works).

Crossfilter is actually firing the following error on server side:

```
4645-ba6f-6122d76d1250/CrossFilter/37f1c91a-0848-47bf-8d26-4d3105d52bd2/ [PUT]
Traceback (most recent call last):
  File "C:\Anaconda\envs\pybokeh27\lib\site-packages\flask\app.py", line 1817, i
n wsgi_app
    response = self.full_dispatch_request()
  File "C:\Anaconda\envs\pybokeh27\lib\site-packages\flask\app.py", line 1477, i
n full_dispatch_request
    rv = self.handle_user_exception(e)
  File "C:\Anaconda\envs\pybokeh27\lib\site-packages\flask\app.py", line 1381, i
n handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "C:\Anaconda\envs\pybokeh27\lib\site-packages\flask\app.py", line 1475, i
n full_dispatch_request
    rv = self.dispatch_request()
  File "C:\Anaconda\envs\pybokeh27\lib\site-packages\flask\app.py", line 1461, i
n dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "C:\dev\repos\bokeh\bokeh\server\views\backbone.py", line 257, in _handle
_specific_model_put
    return _handle_specific_model(docid, typename, id, request.method)
  File "C:\dev\repos\bokeh\bokeh\server\crossdomain.py", line 33, in wrapped_fun
ction
    resp = make_response(f(*args, **kwargs))
  File "C:\dev\repos\bokeh\bokeh\server\views\backbone.py", line 218, in _handle
_specific_model
    return update(docid, typename, id)
  File "C:\dev\repos\bokeh\bokeh\server\views\bbauth.py", line 25, in wrapper
    return func(docid, *args, **kwargs)
  File "C:\dev\repos\bokeh\bokeh\server\views\backbone.py", line 319, in update
    clientdoc.load(modeldata, events='existing', dirty=True)
  File "C:\dev\repos\bokeh\bokeh\document.py", line 251, in load
    props = m.finalize(self._models)
  File "C:\dev\repos\bokeh\bokeh\plot_object.py", line 177, in finalize
    attrs[name] = prop.from_json(json, models=models)
  File "C:\dev\repos\bokeh\bokeh\properties.py", line 895, in from_json
    raise DeserializationError("%s failed to deserilize reference to %s" % (self
, json))
DeserializationError: Instance(PlotObject) failed to deserilize reference to {u'
type': u'Plot', u'id': u'ef72242f-c83c-4275-95f3-b37345173339'}
```



Discussion:
Crossfilter and sliders_app are working for me. Stock_applet is still broken. Here's the traceback:

```
Traceback (most recent call last):
  File "/Users/fpliger/anaconda/envs/pybokeh27/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Users/fpliger/anaconda/envs/pybokeh27/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/Users/fpliger/anaconda/envs/pybokeh27/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/fpliger/anaconda/envs/pybokeh27/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/fpliger/anaconda/envs/pybokeh27/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/fpliger/anaconda/envs/pybokeh27/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/fpliger/anaconda/envs/pybokeh27/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/fpliger/anaconda/envs/pybokeh27/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/fpliger/dev/repos/bokeh/examples/app/stock_applet/flask_server.py", line 28, in applet
    applet = make_stock_applet()
  File "/Users/fpliger/dev/repos/bokeh/bokeh/pluginutils.py", line 21, in wrapper
    obj.tag = tag
  File "/Users/fpliger/dev/repos/bokeh/bokeh/properties.py", line 549, in __setattr__
    (name, self.__class__.__name__, text, nice_join(matches)))
AttributeError: unexpected attribute 'tag' to StockApp, similar attributes are tags
```

OK, it's really odd to me that this works anywhere, given our properties validation system. Here is the offending line in question:

https://github.com/bokeh/bokeh/blob/master/bokeh/pluginutils.py#L21

@hhuuggoo what is the intent of storing the tag on the object like that? @fpliger can you comment out that line in `pluginutils.py` and see if the example works everywhere?

@bryevdv no, it doesn't because the example needs the tag script generated in that line. It fails here:

https://github.com/bokeh/bokeh/blob/master/examples/app/stock_applet/flask_server.py#L32

OK, well as I said that's weird I would expect it to fail everywhere. @mattpap any idea why that only fails on Windows? @hhuuggoo any suggestion? As it is our serializable objects don't (ostensibly) support setting new attributes like `tag` on them. We could add a `tag` attr to plot objects, or create thin wrapper class that just has `tag` and the plot object... open to suggestions.

@bryevdv wait.. it's failing on OSX too for me (not at the time I opened the issue IIRC). 

OK, well that makes more sense. :) Do the other examples not use `pluginutils.app_document`? What do they do?

The failure is pretty obvious (disregarding platform specificity), change `obj.tag = tag` to `obj.tags = [tag]` and it should work. On the other hand, I'm not sure what's the point of this line at all, given that `tag = autoload_server(...)` and `autoload_server()` returns HTML.

they use (see https://github.com/bokeh/bokeh/blob/master/examples/app/crossfilter/crossfilter_app.py#L8):

```
@bokeh_app.route("/bokeh/crossfilter/")
@object_page("crossfilter")
```

That stuff was written before we had tags at all - it's not a tag in that sense, it's the html tag that a user can use to embed into their app.  The idea was to give the users a decorator they could use which would wrap a function returning a plot object, and then they could embed it into web pages.  I guess we need a better way to do this, however I'm not sure what we should do - I really dislike decorators that modify function signatures

we have to generate a new document for the user so there's no good way for them to know the id of the doc we generated

It's not allowed any more to set arbitrary public members on instances of `HasProps` class. You can set private members however, so setting `obj._tag` and adding `tag` property should work (EDIT: by property I mean `@property`).


Resolving patch:
diff --git a/bokeh/pluginutils.py b/bokeh/pluginutils.py
--- a/bokeh/pluginutils.py
+++ b/bokeh/pluginutils.py
@@ -18,7 +18,7 @@ def wrapper(*args, **kwargs):
 
             obj = func(*args, **kwargs)
             tag = embed.autoload_server(obj, session)
-            obj.tag = tag
+            obj._tag = tag
 
             curdoc().add(obj)
             changed = session.store_document(curdoc())
diff --git a/examples/app/stock_applet/flask_server.py b/examples/app/stock_applet/flask_server.py
--- a/examples/app/stock_applet/flask_server.py
+++ b/examples/app/stock_applet/flask_server.py
@@ -29,7 +29,7 @@ def applet():
     return render_template(
         "stocks.html",
         app_url = bokeh_url + "/bokeh/jsgenerate/VBox/StockApp/StockApp",
-        app_tag = applet.tag
+        app_tag = applet._tag
     )
 
 if __name__ == "__main__":


Test patch: