@@ -299,9 +299,10 @@ class PlotlyDict(dict):
299299 def __init__ (self , * args , ** kwargs ):
300300 class_name = self .__class__ .__name__
301301
302- for src in ('xsrc' , 'ysrc' ):
303- if src in kwargs and isinstance (kwargs [src ], Column ):
304- kwargs [src ] = self ._assign_id_to_src (src , kwargs [src ])
302+ for key in kwargs :
303+ if utils .is_source_key (key ):
304+ #if src in kwargs and isinstance(kwargs[src], Column):
305+ kwargs [key ] = self ._assign_id_to_src (key , kwargs [key ])
305306
306307 super (PlotlyDict , self ).__init__ (* args , ** kwargs )
307308 if issubclass (NAME_TO_CLASS [class_name ], PlotlyTrace ):
@@ -314,20 +315,43 @@ def __init__(self, *args, **kwargs):
314315 "a user interface." )
315316
316317 def __setitem__ (self , key , value ):
318+
317319 if key in ('xsrc' , 'ysrc' ):
318320 value = self ._assign_id_to_src (key , value )
319321
320322 return super (PlotlyDict , self ).__setitem__ (key , value )
321323
322324 def _assign_id_to_src (self , src_name , src_value ):
323- if isinstance (src_value , Column ):
324- if src_value .id == '' :
325+ if isinstance (src_value , basestring ):
326+ src_id = src_value
327+ else :
328+ try :
329+ src_id = src_value .id
330+ except :
331+ err = ("{} does not have an `id` property. "
332+ "{} needs to be assigned to either an "
333+ "object with an `id` (like a "
334+ "plotly.grid_objs.Column) or a string. "
335+ "The `id` is a unique identifier "
336+ "assigned by the Plotly webserver "
337+ "to this grid column." )
338+ src_value_str = str (src_value )
339+ err = err .format (src_name , src_value_str )
340+ raise exceptions .InputError (err )
341+
342+ if src_id == '' :
343+ if isinstance (src_value , Column ):
325344 err = exceptions .COLUMN_NOT_YET_UPLOADED_MESSAGE
326345 err .format (column_name = src_value .name , reference = src_name )
327346 raise exceptions .InputError (err )
328347 else :
329- src_value = src_value .id
330- return src_value
348+ err = ("{} should be a unique identifier "
349+ "string assigned by the Plotly "
350+ "server to this to this grid column, "
351+ "not an empty string." .format (src_name ))
352+ raise exceptions .InputError (err )
353+
354+ return src_id
331355
332356 def update (self , dict1 = None , ** dict2 ):
333357 """Update current dict with dict1 and then dict2.
0 commit comments