How to use the turbojson.jsonify.encode function in TurboJson

To help you get started, we’ve selected a few TurboJson examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github beaker-project / beaker / Server / bkr / server / widgets.py View on Github external
if 'simplesearch_label' in kw:
            self.simplesearch_label = kw['simplesearch_label']
        else:
            self.simplesearch_label = 'Search'

        self.button_widget = MyButton(name='quick_search')
        self.quickly_searches = []
        if 'quick_searches' in kw:
            if kw['quick_searches'] is not None: 
                for elem,name in kw['quick_searches']:
                    vals = elem.split('-')
                    if len(vals) != 3:
                        log.error('Quick searches expects vals as --. The following is incorrect: %s' % (elem)) 
                    else: 
                        self.quickly_searches.append((name, '%s-%s-%s' % (vals[0],vals[1],vals[2])))
        self.date_picker = jsonify.encode(kw.get('date_picker',list()) )
        controllers = kw.get('table_search_controllers',dict())  
        self.table_search_controllers_stringified = str(controllers)
        self.to_json = UtilJSON.dynamic_json()
        self.extra_callbacks_stringified = str(self.extra_callbacks)
        self.fields.extend(new_inputs)
        self.fields.extend(new_selects)
github beaker-project / beaker / Server / bkr / server / widgets.py View on Github external
self.search_controller=search_controller
        self.repetitions = 1
        self.extra_hiddens = extra_hiddens
        self.default_result_columns = {}
        table_field = SingleSelectFieldJSON(name="table", options=table, validator=validators.NotEmpty()) 
        operation_field = SingleSelectFieldJSON(name="operation", options=[None], validator=validators.NotEmpty())
        value_field = TextFieldJSON(name="value")

        # We don't know where in the fields array the operation array will be, so we will put it here
        # to access in the template
        self.this_operations_field = operation_field
        self.this_searchvalue_field = value_field
        self.fields = [table_field, operation_field, value_field]
        new_selects = []
        self.extra_callbacks = {} 
        self.search_object = jsonify.encode(complete_data)
            
        if extra_selects is not None: 
            new_class = [] 
            for elem in extra_selects:
                if elem.has_key('display'):
                    if elem['display'] == 'none':
                        new_class.append('hide_parent')
                callback = elem.get('callback',None)
                if callback:
                    self.extra_callbacks[elem['name']] = callback 
                new_select = SingleSelectFieldJSON(name=elem['name'],options=[None], css_classes = new_class, validator=validators.NotEmpty(),for_column=elem['column'] )
                if elem['name'] == 'keyvalue':
                    self.keyvaluevalue = new_select
 
                if elem.has_key('pos'):
                    self.fields.insert(elem['pos'] - 1,new_select)
github beaker-project / beaker / Server / bkr / server / widgets.py View on Github external
def update_params(self, d):
        super(JobActionWidget, self).update_params(d)
        d['job_details']['onclick'] = "JobDelete('%s',%s, %s)" % (
            d.get('action'),
            jsonify.encode({'t_id': d['job_details'].get('t_id')}),
            jsonify.encode(self.get_options(d)),
            )
github beaker-project / beaker / Server / bkr / server / widgets.py View on Github external
     @classmethod
     def __return_array_of_json(cls,x):
         if x:
             jsonified_fields = [jsonify.encode(elem) for elem in x]
             return ','.join(jsonified_fields)
             """
             FIXME Add in here support for non-lists, something like:
             if isinstance(x, list):
                 jsonified_fields = [jsonify.encode(elem) for elem in x]
                 return_json = ','.join(jsonified_fields)
             else:
                 jsonified_fields = jsonify.encode(x)
                 return_json = jsonified_fields
             return return_json
             """
github beaker-project / beaker / Server / bkr / server / widgets.py View on Github external
def display(self, value=None, **params): 
        if 'options' in params: 
            if 'columns' in params['options']:
	        params['columns'] = params['options']['columns']
            if 'simplesearch' in params['options']:
                params['simplesearch'] = params['options']['simplesearch']     
            if 'result_columns' in params['options']:
                json_this = {} 
                for elem in params['options']['result_columns']: 
                    json_this.update({elem : 1})
                params['default_result_columns'] = jsonify.encode(json_this)     
            else:
                params['default_result_columns'] = 'null'
            if 'col_options' in params['options']:
                params['col_options'] = params['options']['col_options']
            else:
                params['col_options'] = []
            if 'col_defaults' in params['options']:
                params['col_defaults'] = params['options']['col_defaults']
            if 'enable_custom_columns' in params['options']:
                params['enable_custom_columns'] = params['options']['enable_custom_columns']
            if 'extra_hiddens' in params['options']:
                params['extra_hiddens'] = [(k,v) for k,v in params['options']['extra_hiddens'].iteritems()] 

        if value and not 'simplesearch' in params:
            params['advanced'] = 'True'
            params['simple'] = 'none'

TurboJson

Python template plugin that supports JSON

MIT
Latest version published 13 years ago

Package Health Score

39 / 100
Full package analysis

Similar packages