From 3505e372d860075fd9b7c506f5da146804924740 Mon Sep 17 00:00:00 2001 From: Andrew Willimott Date: Mon, 8 May 2017 06:40:50 +1200 Subject: [PATCH 1/5] Remove graphviz graph code from appadmin and design files --- applications/admin/controllers/appadmin.py | 60 ------------------- applications/admin/views/appadmin.html | 49 +++++---------- applications/admin/views/default/design.html | 2 - applications/examples/controllers/appadmin.py | 60 ------------------- applications/examples/views/appadmin.html | 49 +++++---------- applications/welcome/controllers/appadmin.py | 60 ------------------- applications/welcome/views/appadmin.html | 49 +++++---------- 7 files changed, 42 insertions(+), 287 deletions(-) diff --git a/applications/admin/controllers/appadmin.py b/applications/admin/controllers/appadmin.py index e72b3dab..bd4d2966 100644 --- a/applications/admin/controllers/appadmin.py +++ b/applications/admin/controllers/appadmin.py @@ -12,12 +12,6 @@ import gluon.contenttype import gluon.fileutils from gluon._compat import iteritems -# d3_graph_model added but leaving pygraphviz code as is for initial tests. -try: - import pygraphviz as pgv -except ImportError: - pgv = None - is_gae = request.env.web2py_runtime_gae or False # ## critical --- make a copy of the environment @@ -566,60 +560,6 @@ def table_template(table): _cellborder=0, _cellspacing=0) ).xml() - -# d3_graph_model added but leaving pygraphviz code as is for initial tests. -# The Graph Model button in admin app views/default/design.html has been redirected -# to the d3_graph_model function. -def bg_graph_model(): - graph = pgv.AGraph(layout='dot', directed=True, strict=False, rankdir='LR') - - subgraphs = dict() - for tablename in db.tables: - if hasattr(db[tablename],'_meta_graphmodel'): - meta_graphmodel = db[tablename]._meta_graphmodel - else: - meta_graphmodel = dict(group=request.application, color='#ECECEC') - - group = meta_graphmodel['group'].replace(' ', '') - if group not in subgraphs: - subgraphs[group] = dict(meta=meta_graphmodel, tables=[]) - subgraphs[group]['tables'].append(tablename) - - graph.add_node(tablename, name=tablename, shape='plaintext', - label=table_template(tablename)) - - for n, key in enumerate(subgraphs.iterkeys()): - graph.subgraph(nbunch=subgraphs[key]['tables'], - name='cluster%d' % n, - style='filled', - color=subgraphs[key]['meta']['color'], - label=subgraphs[key]['meta']['group']) - - for tablename in db.tables: - for field in db[tablename]: - f_type = field.type - if isinstance(f_type,str) and ( - f_type.startswith('reference') or - f_type.startswith('list:reference')): - referenced_table = f_type.split()[1].split('.')[0] - n1 = graph.get_node(tablename) - n2 = graph.get_node(referenced_table) - graph.add_edge(n1, n2, color="#4C4C4C", label='') - - graph.layout() - if not request.args: - response.headers['Content-Type'] = 'image/png' - return graph.draw(format='png', prog='dot') - else: - response.headers['Content-Disposition']='attachment;filename=graph.%s'%request.args(0) - if request.args(0) == 'dot': - return graph.string() - else: - return graph.draw(format=request.args(0), prog='dot') - -def graph_model(): - return dict(databases=databases, pgv=pgv) - def manage(): tables = manager_action['tables'] if isinstance(tables[0], str): diff --git a/applications/admin/views/appadmin.html b/applications/admin/views/appadmin.html index c92e4058..5330b163 100644 --- a/applications/admin/views/appadmin.html +++ b/applications/admin/views/appadmin.html @@ -233,43 +233,22 @@
{{pass}} -{{if request.function=='graph_model':}} -

{{=T("Graph Model")}}

- {{if not pgv:}} - {{=T('pygraphviz library not found')}} - {{elif not databases:}} - {{=T("No databases in this application")}} - {{else:}} -
- - {{=T('Save model as...')}} - - - -
-
- {{=IMG(_src=URL('appadmin', 'bg_graph_model'))}} - {{pass}} -{{pass}} - {{if request.function=='d3_graph_model':}}

{{=T("Graph Model")}}

-
- - -{{pass}} + {{if not databases:}} + {{=T("No databases in this application")}} + {{else:}} +
+ + + {{pass}} +{{pass}} {{if request.function == 'manage':}}

{{=heading}}

diff --git a/applications/admin/views/default/design.html b/applications/admin/views/default/design.html index ec3ca099..5b81f83a 100644 --- a/applications/admin/views/default/design.html +++ b/applications/admin/views/default/design.html @@ -107,8 +107,6 @@ def deletefile(arglist, vars={}): {{pass}} {{if os.access(os.path.join(request.folder,'..',app,'static','js','d3_graph.js'),os.R_OK):}} {{=button(URL(a=app, c='appadmin',f='d3_graph_model'), T('graph model'))}} - {{else:}} - {{=button(URL(a=app, c='appadmin',f='graph_model'), T('graph model'))}} {{pass}}