El sábado, 15 de diciembre de 2012 13:23:30 UTC-3, Massimo Di Pierro
escribió:
>
> Thank you! I will look at this asap.
>
>
please use this latest patch
--
--- /home/jose/web2py/applications/welcome/controllers/appadmin.py 2012-11-25 09:32:54.000000000 -0300
+++ /home/jose/trabajos/dbfw2p/web2py/applications/modelografico/controllers/appadmin.py 2012-12-15 13:31:41.000000000 -0300
@@ -460,3 +460,58 @@
return dict(form=form, total=total,
ram=ram, disk=disk, object_stats=hp != False)
+
+
+
+def table_template(table):
+ def f(x):
+ if x.type == 'string':
+ return x.length
+
+ elif x.type == 'id':
+ return B('pk')
+ elif x.type.find('reference') >= 0:
+ return B('fk')
+ else:
+ return ' '
+
+ header = '''<TR><TD COLSPAN="3" CELLPADDING="4" ALIGN="CENTER" BGCOLOR="#FFA21F"><FONT FACE="Helvetica Bold" COLOR="white">%s</FONT></TD></TR>'''%table
+
+ fields = []
+ for field in db[table].fields:
+ fields.append(
+ '''
+ <TR>
+ <TD ALIGN="LEFT" CELLPADDING="4" BORDER="0"><FONT COLOR="#7B7B7B" FACE="Helvetica Bold">%s</FONT></TD>
+ <TD ALIGN="LEFT" CELLPADDING="4" BORDER="0"><FONT COLOR="#7B7B7B" FACE="Helvetica">%s</FONT></TD>
+ <TD ALIGN="CENTER" CELLPADDING="4" BORDER="0"><FONT COLOR="#7B7B7B" FACE="Helvetica">%s</FONT></TD>
+ </TR>
+ '''%(db[table][field].name, db[table][field].type, f(db[table][field])))
+
+ return '''< <TABLE BGCOLOR="#F1F2AD" BORDER="1" CELLBORDER="0" CELLSPACING="0">%s,%s</TABLE> >'''%(header, ' '.join(fields))
+
+
+
+def bg_graph_model():
+ import pygraphviz as pgv
+
+ A=pgv.AGraph(layout='dot', directed=True, strict=False, rankdir='LR')
+ for table in db.tables:
+ A.add_node(table, name=table, shape='plaintext', label=table_template(table))
+
+
+ for table in db.tables:
+ for n, field in enumerate(db[table].fields):
+ f_type = db[table][field].type
+ if f_type.find('reference') >= 0:
+ referenced_table = f_type.split()[1]
+ n1 = A.get_node(table)
+ n2 = A.get_node(referenced_table)
+
+ A.add_edge(n1, n2, color="#4C4C4C")
+
+ A.layout()
+ return A.draw(format='png', prog='dot')
+
+def graph_model():
+ return dict(databases=databases)