Graph Model (proposal to contribute)

794 views
Skip to first unread message

Jose

unread,
Dec 15, 2012, 9:49:48 AM12/15/12
to web...@googlegroups.com
Hi

I modified the admin and welcome, to allow create a model  graph.

The click in button "grahp model" shows something like:


depends only of pygraphviz.

Best Regards,
Jose

Massimo Di Pierro

unread,
Dec 15, 2012, 10:29:27 AM12/15/12
to web...@googlegroups.com
Did you code this already? Can you send the code. I like it a lot.

Jose

unread,
Dec 15, 2012, 10:58:19 AM12/15/12
to web...@googlegroups.com


El sábado, 15 de diciembre de 2012 12:29:27 UTC-3, Massimo Di Pierro escribió:
Did you code this already? Can you send the code. I like it a lot.

Hi Massimo,

Lack control if installed pygraphviz!

[design.html.patch] -> in admin 
[appadmin.html.patch] -> in welcome
[appadmin.py.patch] -> in welcome

Jose
appadmin.html.patch
appadmin.py.patch
design.html.patch

Massimo Di Pierro

unread,
Dec 15, 2012, 11:23:30 AM12/15/12
to web...@googlegroups.com
Thank you! I will look at this asap.

Jose

unread,
Dec 15, 2012, 11:32:11 AM12/15/12
to web...@googlegroups.com


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 
appadmin.py.patch

Jose

unread,
Dec 15, 2012, 7:06:21 PM12/15/12
to web...@googlegroups.com
new patch with small changes

Jose
appadmin.py.patch

Ovidio Marinho

unread,
Dec 15, 2012, 7:38:40 PM12/15/12
to web...@googlegroups.com
Very Well Jose.
      


       Ovidio Marinho Falcao Neto
                Web Developer
             ovid...@gmail.com 
          ovidio...@itjp.net.br
                 ITJP - itjp.net.br
               83   8826 9088 - Oi
               83   9336 3782 - Claro
                        Brasil
              



2012/12/15 Jose <jja...@gmail.com>
new patch with small changes


Jose

--
 
 
 

António Ramos

unread,
Dec 19, 2012, 10:49:04 AM12/19/12
to web...@googlegroups.com
Is this in trunk?



2012/12/16 Ovidio Marinho <ovid...@gmail.com>
--
 
 
 

Massimo Di Pierro

unread,
Dec 19, 2012, 5:50:53 PM12/19/12
to web...@googlegroups.com
Not yet. It is the queue.....

Jose

unread,
Dec 25, 2012, 10:45:31 AM12/25/12
to web...@googlegroups.com


El miércoles, 19 de diciembre de 2012 19:50:53 UTC-3, Massimo Di Pierro escribió:
Not yet. It is the queue.....

Hello Massimo.

I saw this and was implemented in the trunk.

A new application is created from the welcome folder or from welcome.w2p?
I created an application and is not available the code that implements graph model.

Best Regards
Jose 

Alan Etkin

unread,
Dec 25, 2012, 12:21:00 PM12/25/12
to web...@googlegroups.com
> On Tuesday, December 25, 2012 12:45:31 PM UTC-3, Jose wrote:
El miércoles, 19 de diciembre de 2012 19:50:53 UTC-3, Massimo Di Pierro escribió:
Not yet. It is the queue.....

If you are using mercurial trunk with Linux try:

web2py path]$ touch NEWINSTALL

And restart web2py. I think this is required for updating the welcome installer.

I tried the graph action but complains about "pygraphviz library not found"

Alan Etkin

unread,
Dec 25, 2012, 2:37:46 PM12/25/12
to web...@googlegroups.com
El martes, 25 de diciembre de 2012 12:45:31 UTC-3, Jose escribió:

El miércoles, 19 de diciembre de 2012 19:50:53 UTC-3, Massimo Di Pierro escribió:
Not yet. It is the queue.....

I've moved the table style to web2py.css and changed the xml generation with helpers to cleanup appadmin. Attached are the proposed diffs for appadmin.py and web2py.css.

Does this feature anything else but model visualization (so far)?. I mean, can I manage table definitions with clic and drag, etc?

web2py.css.graph.diff
appadmin.py.graph.cleanup.diff

Alan Etkin

unread,
Dec 25, 2012, 3:44:01 PM12/25/12
to web...@googlegroups.com
I've moved the table style to web2py.css and changed the xml generation with helpers to cleanup appadmin. Attached are the proposed diffs for appadmin.py and web2py.css.


Oops! That would never work (sorry, I didn't know the library requires special html input). This new patch instead uses helpers for creating the model image. Forget about the css diff (it's useless).

appadmin.py.graph_model.with.helpers.diff

Jose

unread,
Dec 25, 2012, 4:26:59 PM12/25/12
to web...@googlegroups.com


El martes, 25 de diciembre de 2012 14:21:00 UTC-3, Alan Etkin escribió:
> On Tuesday, December 25, 2012 12:45:31 PM UTC-3, Jose wrote:
El miércoles, 19 de diciembre de 2012 19:50:53 UTC-3, Massimo Di Pierro escribió:
Not yet. It is the queue.....

If you are using mercurial trunk with Linux try:

web2py path]$ touch NEWINSTALL

And restart web2py. I think this is required for updating the welcome installer.

work, thanks .

Jose

Jose

unread,
Dec 26, 2012, 7:01:51 AM12/26/12
to web...@googlegroups.com


El martes, 25 de diciembre de 2012 17:44:01 UTC-3, Alan Etkin escribió:
I've moved the table style to web2py.css and changed the xml generation with helpers to cleanup appadmin. Attached are the proposed diffs for appadmin.py and web2py.css.


Oops! That would never work (sorry, I didn't know the library requires special html input). This new patch instead uses helpers for creating the model image. Forget about the css diff (it's useless).

Hi Alan

in your patch [*1], face = "Helvetica Bold", it always makes it bold. Originally this was not so, there in bold text (fields, pk, fk) and standard texts (field type, length).

regards
Jose


[*1] 
rows = []
cellpadding = 4
color = "#7B7B7B"
bgcolor = "#F1F2AD"
face = "Helvetica Bold"
border = 0
... 

Jose

unread,
Dec 26, 2012, 11:36:41 AM12/26/12
to web...@googlegroups.com
 this patches it.

Jose
appadmin.py.patch

Alan Etkin

unread,
Dec 28, 2012, 9:24:37 AM12/28/12
to web...@googlegroups.com
Too bad graphviz does not accept css (and  the "< <source> >" is weird also). I wonder if there is any alternative library with similar functionality. Maybe something to produce an svg visual model with a simple API. Am I asking too much?

Luc Chase

unread,
Dec 28, 2012, 1:15:34 PM12/28/12
to web...@googlegroups.com
Hi,
just to clarify please... is this to show the model using a graphical model?
Or is it for extending the DAL to support Graph database models ?

--
Luc.

António Ramos

unread,
Dec 28, 2012, 1:34:49 PM12/28/12
to web...@googlegroups.com
D3js

2012/12/28 Alan Etkin <spam...@gmail.com>
Too bad graphviz does not accept css (and  the "< <source> >" is weird also). I wonder if there is any alternative library with similar functionality. Maybe something to produce an svg visual model with a simple API. Am I asking too much?


--
 
 
 

Massimo Di Pierro

unread,
Dec 28, 2012, 3:16:20 PM12/28/12
to web...@googlegroups.com
I would very much prefer if the graph were generated in JS instead of using serverside code.

Alan Etkin

unread,
Dec 28, 2012, 6:28:39 PM12/28/12
to web...@googlegroups.com
> El viernes, 28 de diciembre de 2012 15:34:49 UTC-3, Ramos escribió:D3js

I'm looking at the awsome examples of D3.js at http://d3js.org/

The thing is that I can't find anything pre-built to show a relational database scheme as graphviz does.

António Ramos

unread,
Dec 28, 2012, 7:09:44 PM12/28/12
to web...@googlegroups.com
D3js seems Awsome. Its already included in Meteorjs 

http://www.dashingd3js.com/table-of-contents




2012/12/28 Alan Etkin <spam...@gmail.com>
> El viernes, 28 de diciembre de 2012 15:34:49 UTC-3, Ramos escribió:D3js

I'm looking at the awsome examples of D3.js at http://d3js.org/

The thing is that I can't find anything pre-built to show a relational database scheme as graphviz does.

--
 
 
 

Jose

unread,
Dec 29, 2012, 8:49:02 AM12/29/12
to web...@googlegroups.com


El viernes, 28 de diciembre de 2012 15:15:34 UTC-3, Luc Chase escribió:
Hi,
just to clarify please... is this to show the model using a graphical model?
Or is it for extending the DAL to support Graph database models ?

--
Luc.

Only shows the database model graphically 

José

Jose

unread,
Dec 29, 2012, 8:53:17 AM12/29/12
to web...@googlegroups.com
This can be useful?

1) Save the model
2) Show auth_xxxx tables different from other

If you want to send the patch.
Jose

save_as.png
tables_auth.png

Massimo Di Pierro

unread,
Dec 29, 2012, 11:49:27 AM12/29/12
to web...@googlegroups.com
I'll take the patch. ;-)
Please use colors which look when printed in black and white.

Jose

unread,
Dec 29, 2012, 7:20:22 PM12/29/12
to web...@googlegroups.com
I like different colors to gray...

You can add more formats to download:

‘canon’, ‘cmap’, ‘cmapx’, ‘cmapx_np’, ‘dia’, ‘dot’, ‘fig’, ‘gd’, ‘gd2’, ‘gif’, ‘hpgl’, ‘imap’, ‘imap_np’, ‘ismap’, ‘jpe’, ‘jpeg’, ‘jpg’, ‘mif’, ‘mp’, ‘pcl’, ‘pdf’, ‘pic’, ‘plain’, ‘plain-ext’, ‘png’, ‘ps’, ‘ps2’, ‘svg’, ‘svgz’, ‘vml’, ‘vmlz’, ‘vrml’, ‘vtx’, ‘wbmp’, ‘xdot’, ‘xlib’

José
appadmin.html.patch
appadmin.py.patch

Bruno Rocha

unread,
Dec 29, 2012, 7:22:47 PM12/29/12
to web...@googlegroups.com


On Sat, Dec 29, 2012 at 10:20 PM, Jose <jja...@gmail.com> wrote:
‘dia’

It exports on to an editable dia diagram?

I have to test it!

Jose

unread,
Dec 29, 2012, 9:11:04 PM12/29/12
to

 Formats (not all may be available on every system depending on how Graphviz was built)
‘canon’, ‘cmap’, ‘cmapx’, ‘cmapx_np’, ‘dia’, ‘dot’, ‘fig’, ‘gd’, ‘gd2’, ‘gif’, ‘hpgl’, ‘imap’, ‘imap_np’, ‘ismap’, ‘jpe’, ‘jpeg’, ‘jpg’, ‘mif’, ‘mp’, ‘pcl’, ‘pdf’, ‘pic’, ‘plain’, ‘plain-ext’, ‘png’, ‘ps’, ‘ps2’, ‘svg’, ‘svgz’, ‘vml’, ‘vmlz’, ‘vrml’, ‘vtx’, ‘wbmp’, ‘xdot’, ‘xlib’

In my system I have not compiled graphviz with support for dia.

Jose

unread,
Dec 29, 2012, 7:57:04 PM12/29/12
to web...@googlegroups.com
dia can load svg files!

Jose

Jose

unread,
Jan 3, 2013, 11:22:51 AM1/3/13
to web...@googlegroups.com
Hi Massimo

You could add some arguments in define_table as meta_group, meta_description, etc. These can be useful for the generation of the graphical model and also as documentation.

In the screenshot looks for tables auth. In this case it is simple for a convention in the names
subgraph.png

pablo....@uam.es

unread,
Feb 18, 2013, 9:51:32 AM2/18/13
to web...@googlegroups.com

Thanks a ton, Jose, I did a much more modest attempt at the same thing:

print 'digraph Bloques{\n' \
     
'ranksep="2"\n' \
     
'splines="true"\n'
for table in db:
   
for field in table:
       
if field.type.startswith('reference'):
            t
= '%s -> %s'%(table, field.type[10:])
            type
= field.type[10:]
       
elif field.type.startswith('list:reference'):
            t
= '%s -> %s [arrowhead="veevee" ]'%(table, field.type[15:])
       
else: continue
       
if field.name!=type:
             t
+= '[ label = "%s" ]'%field.name
       
print t
print '}'


This generates a diagram with only the references between the tables, labeling the arrows if the field name is different from the target table.
Calling

dot -Tpng db.dot -o db_picture.png

gives a file like in the example above.

BTW; have you considered using canviz?:

http://code.google.com/p/canviz/

I'm not sure it does what Massimo wants, because it might need the coordinates of the points, that are obtained with a call to 'dot'.

Regards

Niphlod

unread,
Feb 18, 2013, 10:18:37 AM2/18/13
to web...@googlegroups.com
the only issue with the current implementation in trunk is that on Windows it's almost impossible to get it going, due to the requirements.

António Ramos

unread,
Feb 18, 2013, 10:33:41 AM2/18/13
to web...@googlegroups.com
D3js pure javascript on client!

see this example of meteorjs using d3js


That is something...



2013/2/18 Niphlod <nip...@gmail.com>
the only issue with the current implementation in trunk is that on Windows it's almost impossible to get it going, due to the requirements.


--
 
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Andrew Willimott

unread,
Oct 24, 2016, 5:01:57 AM10/24/16
to web2py-users

Has anyone else tried visualising the models with d3js ?  I have a mockup working using the force layout.  I'd suggest this is a better long term approach than relying on graphviz being installed.  (Graphviz has some good layouts though).

I can send cleaned up code as a candidate to add to Welcome.  


Jurgis Pralgauskis

unread,
Nov 6, 2016, 2:45:19 PM11/6/16
to web2py-users
Hi, I would be interested!

Ps.: I made some subgraph/filtering features, when graph model is big (hundreds of tables), but with JS it might work nicer..

António Ramos

unread,
Nov 7, 2016, 3:36:01 AM11/7/16
to web...@googlegroups.com
+1 for D3js..

2016-11-06 19:45 GMT+00:00 Jurgis Pralgauskis <jurgis.pr...@gmail.com>:
Hi, I would be interested!

Ps.: I made some subgraph/filtering features, when graph model is big (hundreds of tables), but with JS it might work nicer..

---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrew Willimott

unread,
Nov 16, 2016, 4:38:19 AM11/16/16
to web2py-users

Richard Vézina

unread,
Nov 16, 2016, 8:57:03 AM11/16/16
to web2py-users
Could we keep both rendering mechanism graphviz + d3?

On Wed, Nov 16, 2016 at 4:38 AM, Andrew Willimott <will...@gmail.com> wrote:

António Ramos

unread,
Nov 16, 2016, 9:58:35 AM11/16/16
to web...@googlegroups.com
+1 for D3
no need to install graphviz and pygraphviz on the server...

Ron Chatterjee

unread,
Nov 16, 2016, 11:49:38 AM11/16/16
to web2py-users
+1.

 Is it going to be standard on next upgrades?


On Wednesday, November 16, 2016 at 9:58:35 AM UTC-5, Ramos wrote:
+1 for D3
no need to install graphviz and pygraphviz on the server...

2016-11-16 13:56 GMT+00:00 Richard Vézina <ml.richa...@gmail.com>:
Could we keep both rendering mechanism graphviz + d3?
On Wed, Nov 16, 2016 at 4:38 AM, Andrew Willimott <will...@gmail.com> wrote:

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.

JorgeH

unread,
Nov 17, 2016, 8:49:55 AM11/17/16
to web2py-users
+1 for D3 here

Donald McClymont

unread,
Nov 19, 2016, 6:35:04 PM11/19/16
to web2py-users
Had a look at this and seems far better way to go as pygraphviz was beyond me to install on windows.  I've been using d3 for some other things with web2py and some degree of interactivity with the graph eg creating new nodes and saving the layout as force directed typically gives you a good starting point but some further manual organisation can help.  It also does seem as suspected some tweaking will be required for larger data models as some of it doesn't appear to show properly on my test.  I am currently working on moving my stuff to d3 v4 which was proving challenging on the interactive graph as I am no expert on d3.  I am hoping this example will help with that and I will see if I can come back with some improvements to this as well.

Regards
Donald

On Thursday, November 17, 2016 at 1:49:55 PM UTC, JorgeH wrote:
+1 for D3 here

Andrew Willimott

unread,
Nov 20, 2016, 12:33:54 PM11/20/16
to web2py-users
Thanks Donald, I'll do another round of improvements and then create a PR. it does need to handle larger models better and I'll improve the code layout too. I'm also learning the d4 differences and there are a lot of future options with using d3.

web2py with a d3 interactive front end is a good topic. Interested to know more as I'm working on this too.

Donald McClymont

unread,
Feb 27, 2017, 4:56:47 PM2/27/17
to web2py-users
Has anyone had a chance to try this out and advise if it is suitable to incorporate in main web2py or if there are some other changes that should be made before it would be acceptable.  There's lots more that could be done with it but it seems quite useful and usable in present form?

Donald

Andrew Willimott

unread,
Mar 1, 2017, 2:45:35 AM3/1/17
to web2py-users
Hi Donald, yes I have , and I have been meaning to some changes (to minimise the overlap in names). Sorry, been busy lately, I'll get on to updating Welcome. My plan is to leave the existing graph code as is until everyone is ok with it. Thanks for following up.
Reply all
Reply to author
Forward
0 new messages