Python xadmin.util.json.dumps() Examples
The following are 30
code examples of xadmin.util.json.dumps().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
xadmin.util.json
, or try the search function
.
Example #1
Source File: base.py From online with GNU Affero General Public License v3.0 | 5 votes |
def render_response(self, content, response_type='json'): if response_type == 'json': response = HttpResponse(content_type="application/json; charset=UTF-8") response.write( json.dumps(content, cls=JSONEncoder, ensure_ascii=False)) return response return HttpResponse(content)
Example #2
Source File: base.py From Mxonline3 with Apache License 2.0 | 5 votes |
def render_response(self, content, response_type='json'): if response_type == 'json': response = HttpResponse(content_type="application/json; charset=UTF-8") response.write( json.dumps(content, cls=JSONEncoder, ensure_ascii=False)) return response return HttpResponse(content)
Example #3
Source File: base.py From StormOnline with Apache License 2.0 | 5 votes |
def render_response(self, content, response_type='json'): if response_type == 'json': response = HttpResponse(content_type="application/json; charset=UTF-8") response.write( json.dumps(content, cls=JSONEncoder, ensure_ascii=False)) return response return HttpResponse(content)
Example #4
Source File: export.py From Mxonline3 with Apache License 2.0 | 5 votes |
def get_json_export(self, context): results = self._get_objects(context) return json.dumps({'objects': results}, ensure_ascii=False, indent=(self.request.GET.get('export_json_format', 'off') == 'on') and 4 or None)
Example #5
Source File: base.py From imoocc with GNU General Public License v2.0 | 5 votes |
def render_response(self, content, response_type='json'): if response_type == 'json': response = HttpResponse(content_type="application/json; charset=UTF-8") response.write( json.dumps(content, cls=JSONEncoder, ensure_ascii=False)) return response return HttpResponse(content)
Example #6
Source File: themes.py From imoocc with GNU General Public License v2.0 | 5 votes |
def block_top_navmenu(self, context, nodes): themes = [ {'name': _(u"Default"), 'description': _(u"Default bootstrap theme"), 'css': self.default_theme}, {'name': _(u"Bootstrap2"), 'description': _(u"Bootstrap 2.x theme"), 'css': self.bootstrap2_theme}, ] select_css = context.get('site_theme', self.default_theme) if self.user_themes: themes.extend(self.user_themes) if self.use_bootswatch: ex_themes = cache.get(THEME_CACHE_KEY) if ex_themes: themes.extend(json.loads(ex_themes)) else: ex_themes = [] try: h = httplib2.Http() resp, content = h.request("https://bootswatch.com/api/3.json", 'GET', '', headers={"Accept": "application/json", "User-Agent": self.request.META['HTTP_USER_AGENT']}) if six.PY3: content = content.decode() watch_themes = json.loads(content)['themes'] ex_themes.extend([ {'name': t['name'], 'description': t['description'], 'css': t['cssMin'], 'thumbnail': t['thumbnail']} for t in watch_themes]) except Exception as e: print(e) cache.set(THEME_CACHE_KEY, json.dumps(ex_themes), 24 * 3600) themes.extend(ex_themes) nodes.append(loader.render_to_string('xadmin/blocks/comm.top.theme.html', {'themes': themes, 'select_css': select_css}))
Example #7
Source File: export.py From imoocc with GNU General Public License v2.0 | 5 votes |
def get_json_export(self, context): results = self._get_objects(context) return json.dumps({'objects': results}, ensure_ascii=False, indent=(self.request.GET.get('export_json_format', 'off') == 'on') and 4 or None)
Example #8
Source File: base.py From devops with MIT License | 5 votes |
def render_response(self, content, response_type='json'): if response_type == 'json': response = HttpResponse(content_type="application/json; charset=UTF-8") response.write( json.dumps(content, cls=JSONEncoder, ensure_ascii=False)) return response return HttpResponse(content)
Example #9
Source File: themes.py From devops with MIT License | 5 votes |
def block_top_navmenu(self, context, nodes): themes = [{'name': _(u"Default"), 'description': _( u"Default bootstrap theme"), 'css': self.default_theme}, {'name': _(u"Bootstrap2"), 'description': _(u"Bootstrap 2.x theme"), 'css': self.bootstrap2_theme}] select_css = context.get('site_theme', self.default_theme) if self.user_themes: themes.extend(self.user_themes) if self.use_bootswatch: ex_themes = cache.get(THEME_CACHE_KEY) if ex_themes: themes.extend(json.loads(ex_themes)) else: ex_themes = [] try: watch_themes = json.loads(urllib.urlopen( 'http://api.bootswatch.com/3/').read())['themes'] ex_themes.extend([ {'name': t['name'], 'description': t['description'], 'css': t['cssMin'], 'thumbnail': t['thumbnail']} for t in watch_themes]) except Exception: pass cache.set(THEME_CACHE_KEY, json.dumps(ex_themes), 24 * 3600) themes.extend(ex_themes) nodes.append(loader.render_to_string('xadmin/blocks/comm.top.theme.html', {'themes': themes, 'select_css': select_css}))
Example #10
Source File: export.py From devops with MIT License | 5 votes |
def get_json_export(self, context): results = self._get_objects(context) return json.dumps({'objects': results}, ensure_ascii=False, indent=(self.request.GET.get('export_json_format', 'off') == 'on') and 4 or None)
Example #11
Source File: themes.py From Mxonline3 with Apache License 2.0 | 5 votes |
def block_top_navmenu(self, context, nodes): themes = [ {'name': _(u"Default"), 'description': _(u"Default bootstrap theme"), 'css': self.default_theme}, {'name': _(u"Bootstrap2"), 'description': _(u"Bootstrap 2.x theme"), 'css': self.bootstrap2_theme}, ] select_css = context.get('site_theme', self.default_theme) if self.user_themes: themes.extend(self.user_themes) if self.use_bootswatch: ex_themes = cache.get(THEME_CACHE_KEY) if ex_themes: themes.extend(json.loads(ex_themes)) else: ex_themes = [] try: h = httplib2.Http() resp, content = h.request("https://bootswatch.com/api/3.json", 'GET', '', headers={"Accept": "application/json", "User-Agent": self.request.META['HTTP_USER_AGENT']}) content = content.decode() watch_themes = json.loads(content)['themes'] ex_themes.extend([ {'name': t['name'], 'description': t['description'], 'css': t['cssMin'], 'thumbnail': t['thumbnail']} for t in watch_themes]) except Exception as e: print(e) cache.set(THEME_CACHE_KEY, json.dumps(ex_themes), 24 * 3600) themes.extend(ex_themes) nodes.append(loader.render_to_string('xadmin/blocks/comm.top.theme.html', {'themes': themes, 'select_css': select_css}))
Example #12
Source File: themes.py From online with GNU Affero General Public License v3.0 | 5 votes |
def block_top_navmenu(self, context, nodes): themes = [ {'name': _(u"Default"), 'description': _(u"Default bootstrap theme"), 'css': self.default_theme}, {'name': _(u"Bootstrap2"), 'description': _(u"Bootstrap 2.x theme"), 'css': self.bootstrap2_theme}, ] select_css = context.get('site_theme', self.default_theme) if self.user_themes: themes.extend(self.user_themes) if self.use_bootswatch: ex_themes = cache.get(THEME_CACHE_KEY) if ex_themes: themes.extend(json.loads(ex_themes)) else: ex_themes = [] try: h = httplib2.Http() resp, content = h.request("https://bootswatch.com/api/3.json", 'GET', '', headers={"Accept": "application/json", "User-Agent": self.request.META['HTTP_USER_AGENT']}) if six.PY3: content = content.decode() watch_themes = json.loads(content)['themes'] ex_themes.extend([ {'name': t['name'], 'description': t['description'], 'css': t['cssMin'], 'thumbnail': t['thumbnail']} for t in watch_themes]) except Exception as e: print(e) cache.set(THEME_CACHE_KEY, json.dumps(ex_themes), 24 * 3600) themes.extend(ex_themes) nodes.append(loader.render_to_string('xadmin/blocks/comm.top.theme.html', {'themes': themes, 'select_css': select_css}))
Example #13
Source File: export.py From online with GNU Affero General Public License v3.0 | 5 votes |
def get_json_export(self, context): results = self._get_objects(context) return json.dumps({'objects': results}, ensure_ascii=False, indent=(self.request.GET.get('export_json_format', 'off') == 'on') and 4 or None)
Example #14
Source File: base.py From Dailyfresh-B2C with Apache License 2.0 | 5 votes |
def render_response(self, content, response_type='json'): if response_type == 'json': response = HttpResponse(content_type="application/json; charset=UTF-8") response.write( json.dumps(content, cls=JSONEncoder, ensure_ascii=False)) return response return HttpResponse(content)
Example #15
Source File: themes.py From Dailyfresh-B2C with Apache License 2.0 | 5 votes |
def block_top_navmenu(self, context, nodes): themes = [ {'name': _(u"Default"), 'description': _(u"Default bootstrap theme"), 'css': self.default_theme}, {'name': _(u"Bootstrap2"), 'description': _(u"Bootstrap 2.x theme"), 'css': self.bootstrap2_theme}, ] select_css = context.get('site_theme', self.default_theme) if self.user_themes: themes.extend(self.user_themes) if self.use_bootswatch: ex_themes = cache.get(THEME_CACHE_KEY) if ex_themes: themes.extend(json.loads(ex_themes)) else: ex_themes = [] try: h = httplib2.Http() resp, content = h.request("https://bootswatch.com/api/3.json", 'GET', '', headers={"Accept": "application/json", "User-Agent": self.request.META['HTTP_USER_AGENT']}) if six.PY3: content = content.decode() watch_themes = json.loads(content)['themes'] ex_themes.extend([ {'name': t['name'], 'description': t['description'], 'css': t['cssMin'], 'thumbnail': t['thumbnail']} for t in watch_themes]) except Exception as e: print(e) cache.set(THEME_CACHE_KEY, json.dumps(ex_themes), 24 * 3600) themes.extend(ex_themes) nodes.append(loader.render_to_string('xadmin/blocks/comm.top.theme.html', {'themes': themes, 'select_css': select_css}))
Example #16
Source File: export.py From Dailyfresh-B2C with Apache License 2.0 | 5 votes |
def get_json_export(self, context): results = self._get_objects(context) return json.dumps({'objects': results}, ensure_ascii=False, indent=(self.request.GET.get('export_json_format', 'off') == 'on') and 4 or None)
Example #17
Source File: base.py From ImitationTmall_Django with GNU General Public License v3.0 | 5 votes |
def render_response(self, content, response_type='json'): if response_type == 'json': response = HttpResponse(content_type="application/json; charset=UTF-8") response.write( json.dumps(content, cls=JSONEncoder, ensure_ascii=False)) return response return HttpResponse(content)
Example #18
Source File: themes.py From ImitationTmall_Django with GNU General Public License v3.0 | 5 votes |
def block_top_navmenu(self, context, nodes): themes = [{'name': _(u"Default"), 'description': _( u"Default bootstrap theme"), 'css': self.default_theme}, {'name': _(u"Bootstrap2"), 'description': _(u"Bootstrap 2.x theme"), 'css': self.bootstrap2_theme}] select_css = context.get('site_theme', self.default_theme) if self.user_themes: themes.extend(self.user_themes) if self.use_bootswatch: ex_themes = cache.get(THEME_CACHE_KEY) if ex_themes: themes.extend(json.loads(ex_themes)) else: ex_themes = [] try: h = httplib2.Http() resp, content = h.request("http://bootswatch.com/api/3.json", 'GET', \ "", headers={"Accept": "application/json", "User-Agent": self.request.META['HTTP_USER_AGENT']}) watch_themes = json.loads(content)['themes'] ex_themes.extend([ {'name': t['name'], 'description': t['description'], 'css': t['cssMin'], 'thumbnail': t['thumbnail']} for t in watch_themes]) except Exception, e: print e cache.set(THEME_CACHE_KEY, json.dumps(ex_themes), 24 * 3600) themes.extend(ex_themes)
Example #19
Source File: export.py From ImitationTmall_Django with GNU General Public License v3.0 | 5 votes |
def get_json_export(self, context): results = self._get_objects(context) return json.dumps({'objects': results}, ensure_ascii=False, indent=(self.request.GET.get('export_json_format', 'off') == 'on') and 4 or None)
Example #20
Source File: themes.py From django_OA with GNU General Public License v3.0 | 5 votes |
def block_top_navmenu(self, context, nodes): themes = [ {'name': _(u"Default"), 'description': _(u"Default bootstrap theme"), 'css': self.default_theme}, {'name': _(u"Bootstrap2"), 'description': _(u"Bootstrap 2.x theme"), 'css': self.bootstrap2_theme}, ] select_css = context.get('site_theme', self.default_theme) if self.user_themes: themes.extend(self.user_themes) if self.use_bootswatch: ex_themes = cache.get(THEME_CACHE_KEY) if ex_themes: themes.extend(json.loads(ex_themes)) else: ex_themes = [] try: h = httplib2.Http() resp, content = h.request("https://bootswatch.com/api/3.json", 'GET', '', headers={"Accept": "application/json", "User-Agent": self.request.META['HTTP_USER_AGENT']}) if six.PY3: content = content.decode() watch_themes = json.loads(content)['themes'] ex_themes.extend([ {'name': t['name'], 'description': t['description'], 'css': t['cssMin'], 'thumbnail': t['thumbnail']} for t in watch_themes]) except Exception as e: print(e) cache.set(THEME_CACHE_KEY, json.dumps(ex_themes), 24 * 3600) themes.extend(ex_themes) nodes.append(loader.render_to_string('xadmin/blocks/comm.top.theme.html', {'themes': themes, 'select_css': select_css}))
Example #21
Source File: export.py From StormOnline with Apache License 2.0 | 5 votes |
def get_json_export(self, context): results = self._get_objects(context) return json.dumps({'objects': results}, ensure_ascii=False, indent=(self.request.GET.get('export_json_format', 'off') == 'on') and 4 or None)
Example #22
Source File: base.py From weibo-analysis-system with MIT License | 5 votes |
def render_response(self, content, response_type='json'): if response_type == 'json': response = HttpResponse(content_type="application/json; charset=UTF-8") response.write( json.dumps(content, cls=JSONEncoder, ensure_ascii=False)) return response return HttpResponse(content)
Example #23
Source File: themes.py From weibo-analysis-system with MIT License | 5 votes |
def block_top_navmenu(self, context, nodes): themes = [ {'name': _(u"Default"), 'description': _(u"Default bootstrap theme"), 'css': self.default_theme}, {'name': _(u"Bootstrap2"), 'description': _(u"Bootstrap 2.x theme"), 'css': self.bootstrap2_theme}, ] select_css = context.get('site_theme', self.default_theme) if self.user_themes: themes.extend(self.user_themes) if self.use_bootswatch: ex_themes = cache.get(THEME_CACHE_KEY) if ex_themes: themes.extend(json.loads(ex_themes)) else: ex_themes = [] try: h = httplib2.Http() resp, content = h.request("https://bootswatch.com/api/3.json", 'GET', '', headers={"Accept": "application/json", "User-Agent": self.request.META['HTTP_USER_AGENT']}) if six.PY3: content = content.decode() watch_themes = json.loads(content)['themes'] ex_themes.extend([ {'name': t['name'], 'description': t['description'], 'css': t['cssMin'], 'thumbnail': t['thumbnail']} for t in watch_themes]) except Exception as e: print(e) cache.set(THEME_CACHE_KEY, json.dumps(ex_themes), 24 * 3600) themes.extend(ex_themes) nodes.append(loader.render_to_string('xadmin/blocks/comm.top.theme.html', {'themes': themes, 'select_css': select_css}))
Example #24
Source File: export.py From weibo-analysis-system with MIT License | 5 votes |
def get_json_export(self, context): results = self._get_objects(context) return json.dumps({'objects': results}, ensure_ascii=False, indent=(self.request.GET.get('export_json_format', 'off') == 'on') and 4 or None)
Example #25
Source File: base.py From myblog with GNU Affero General Public License v3.0 | 5 votes |
def render_response(self, content, response_type='json'): if response_type == 'json': response = HttpResponse(content_type="application/json; charset=UTF-8") response.write( json.dumps(content, cls=JSONEncoder, ensure_ascii=False)) return response return HttpResponse(content)
Example #26
Source File: themes.py From myblog with GNU Affero General Public License v3.0 | 5 votes |
def block_top_navmenu(self, context, nodes): themes = [ {'name': _(u"Default"), 'description': _(u"Default bootstrap theme"), 'css': self.default_theme}, {'name': _(u"Bootstrap2"), 'description': _(u"Bootstrap 2.x theme"), 'css': self.bootstrap2_theme}, ] select_css = context.get('site_theme', self.default_theme) if self.user_themes: themes.extend(self.user_themes) if self.use_bootswatch: ex_themes = cache.get(THEME_CACHE_KEY) if ex_themes: themes.extend(json.loads(ex_themes)) else: ex_themes = [] try: h = httplib2.Http() resp, content = h.request("https://bootswatch.com/api/3.json", 'GET', '', headers={"Accept": "application/json", "User-Agent": self.request.META['HTTP_USER_AGENT']}) if six.PY3: content = content.decode() watch_themes = json.loads(content)['themes'] ex_themes.extend([ {'name': t['name'], 'description': t['description'], 'css': t['cssMin'], 'thumbnail': t['thumbnail']} for t in watch_themes]) except Exception as e: print(e) cache.set(THEME_CACHE_KEY, json.dumps(ex_themes), 24 * 3600) themes.extend(ex_themes) nodes.append(loader.render_to_string('xadmin/blocks/comm.top.theme.html', {'themes': themes, 'select_css': select_css}))
Example #27
Source File: export.py From myblog with GNU Affero General Public License v3.0 | 5 votes |
def get_json_export(self, context): results = self._get_objects(context) return json.dumps({'objects': results}, ensure_ascii=False, indent=(self.request.GET.get('export_json_format', 'off') == 'on') and 4 or None)
Example #28
Source File: base.py From CTF_AWD_Platform with MIT License | 5 votes |
def render_response(self, content, response_type='json'): if response_type == 'json': response = HttpResponse(content_type="application/json; charset=UTF-8") response.write( json.dumps(content, cls=JSONEncoder, ensure_ascii=False)) return response return HttpResponse(content)
Example #29
Source File: themes.py From CTF_AWD_Platform with MIT License | 5 votes |
def block_top_navmenu(self, context, nodes): themes = [ {'name': _(u"Default"), 'description': _(u"Default bootstrap theme"), 'css': self.default_theme}, {'name': _(u"Bootstrap2"), 'description': _(u"Bootstrap 2.x theme"), 'css': self.bootstrap2_theme}, ] select_css = context.get('site_theme', self.default_theme) if self.user_themes: themes.extend(self.user_themes) if self.use_bootswatch: ex_themes = cache.get(THEME_CACHE_KEY) if ex_themes: themes.extend(json.loads(ex_themes)) else: ex_themes = [] try: h = httplib2.Http() resp, content = h.request("https://bootswatch.com/api/3.json", 'GET', '', headers={"Accept": "application/json", "User-Agent": self.request.META['HTTP_USER_AGENT']}) if six.PY3: content = content.decode() watch_themes = json.loads(content)['themes'] ex_themes.extend([ {'name': t['name'], 'description': t['description'], 'css': t['cssMin'], 'thumbnail': t['thumbnail']} for t in watch_themes]) except Exception as e: print(e) cache.set(THEME_CACHE_KEY, json.dumps(ex_themes), 24 * 3600) themes.extend(ex_themes) nodes.append(loader.render_to_string('xadmin/blocks/comm.top.theme.html', {'themes': themes, 'select_css': select_css}))
Example #30
Source File: export.py From CTF_AWD_Platform with MIT License | 5 votes |
def get_json_export(self, context): results = self._get_objects(context) return json.dumps({'objects': results}, ensure_ascii=False, indent=(self.request.GET.get('export_json_format', 'off') == 'on') and 4 or None)