parameters: (self, widget_or_id, data=None)
docstring: 实例化widget
docstring_summary: 实例化widget
docstring_tokens: 实例化widget
function: def get_widget(self, widget_or_id, data=None):
          '''
          实例化widget
          '''
          try:
              if isinstance(widget_or_id, UserWidget):
                  widget = widget_or_id
              else:
                  widget = UserWidget.objects.get(user=self.user, page_id=self.get_page_id(), id=widget_or_id)
              wid = widget_manager.get(widget.widget_type)
  
              class widget_with_perm(wid):
                  def context(self, context):
                      super(widget_with_perm, self).context(context)
                      context.update({'has_change_permission': self.request.user.has_perm('xadmin.change_userwidget')})
              wid_instance = widget_with_perm(self, data or widget.get_value())
              return wid_instance
          except UserWidget.DoesNotExist:
              return None
function_tokens: def get_widget ( self , widget_or_id , data = None ) : try : if isinstance ( widget_or_id , UserWidget ) : widget = widget_or_id else : widget = UserWidget . objects . get ( user = self . user , page_id = self . get_page_id ( ) , id = widget_or_id ) wid = widget_manager . get ( widget . widget_type ) class widget_with_perm ( wid ) : def context ( self , context ) : super ( widget_with_perm , self ) . context ( context ) context . update ( { 'has_change_permission' : self . request . user . has_perm ( 'xadmin.change_userwidget' ) } ) wid_instance = widget_with_perm ( self , data or widget . get_value ( ) ) return wid_instance except UserWidget . DoesNotExist : return None