Absolutly not, you are free to do what do you want.

Only one note. The db_diagram.css file is not optimized because it is a 
reference for the users which would like customize the theme.


Il giorno venerdì 1 febbraio 2013 17:31:50 UTC+1, Massimo Di Pierro ha 
scritto:
>
> Would you be opposed to turn this into an admin plugin and allow appadmin 
> to access it?
>
> On Wednesday, 30 January 2013 15:04:06 UTC-6, Paolo Caruccio wrote:
>>
>> Massimo,
>>
>> thanks for the compliments and for the suggestions.
>> Actually, in my mind the posted code is a sort of appadmin plugin. For 
>> this reason I separated db diagram static files from web2py ones.
>> About the 'db' limitation, it's due to lack of time for testing.
>>
>> I'm attaching a w2p application (modified hotel management appliance) to 
>> show better how it works.
>>
>>
>> Il giorno mercoledì 30 gennaio 2013 19:55:53 UTC+1, Massimo Di Pierro ha 
>> scritto:
>>>
>>> This is really nice. How about we move all the static files and the view 
>>> into admin and he have the db_diagram.py code in appadmin just include form 
>>> admin? we can do that easily. 
>>>
>>> you can do
>>>
>>> dbs = [db in globals().values() if isinstance(db.DAL)]
>>>
>>> to get databases. There is a more efficient way:
>>>
>>> from gluon.dal import THREAD_LOCA
>>> mdbs = getattr(THREAD_LOCAL,'db_instances',{}).items()
>>> dbs = []
>>> for db_uid, db_group in mdbs: dbs += [db for db in db_group]
>>>            
>>>
>>>
>>> On Wednesday, January 30, 2013 10:23:21 AM UTC-6, Paolo Caruccio wrote:
>>>>
>>>> I was not able to succesfully install pygraphviz on my windows7 64bit 
>>>> enviroment but I liked Jose's idea 
>>>> https://groups.google.com/d/topic/web2py/cFqD1M6rkc8/discussion, so I 
>>>> wrote a simple addendum to appadmin in order to show a graph 
>>>> representation 
>>>> of a database.
>>>> It's not alternative to or a replacement of Jose's graph layout because 
>>>> there are substantial differences.
>>>> "db diagram" is interactive (nodes are draggable and clickable) but you 
>>>> cannot save it as an image (anyway it's possible to use a third party 
>>>> application for screenshoots).
>>>> Moreover it is customizable via css (you will find here attached a css 
>>>> theme for reference) and it's based on jqueryUI framewok.
>>>> The nodes contain only the table name, so we can draw the layout of a 
>>>> database with (moderately) numerous tables.
>>>> In order to see table data you have to click on the node. I added some 
>>>> infos like indexed columns (currently available only for sqlite but I 
>>>> think 
>>>> it's not hard to implement for other database engines), the list of other 
>>>> affected  tables when we delete a row in cascade mode.
>>>> The layout (the position of nodes on the screen) is generated trough a 
>>>> force-directed spring algorythm. Therefore the layout is generated 
>>>> dinamically and it will be different each time you refresh the page.
>>>> For this scope, I adapted and translated to jQuery the original 
>>>> prototype source code freely distributed under the terms of a MIT-style 
>>>> license from 
>>>> http://snipplr.com/view/1950/graph-javascript-framework-version-001/
>>>> For a jquery version of this original source code you could visit 
>>>> http://www.graphdracula.net/
>>>> The edges are drawn by jsPlumb library ( 
>>>> http://www.jsplumb.org/jquery/demo.html ). All 1.x.x versions of 
>>>> jsPlumb are dual-licensed under both MIT and GPL version 2.
>>>> Current main limitation: the database must have 'db' key in application 
>>>> databases dictionary. In other words in our model we must have 
>>>> db = DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])
>>>> and not, for example, 
>>>> mydb = DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'
>>>> ])
>>>> The screen dimensions are important too: the layout will be messed on 
>>>> small screens.
>>>> The code has been tested on latest versions of Firefox, Chrome, Opera, 
>>>> IE(7,8,9) and on a very limited number of databases. So please check for 
>>>> errors and bugs.
>>>>
>>>> Installation:
>>>> 1) append the code within in the attached db_diagram.py  in 
>>>> your_application/controllers/appadmin.py file
>>>> 2) put attached db_diagram.html in to your_application/views folder
>>>> 3) create a new folder in your_application/static folder and name it 
>>>> "db_diagram"
>>>> 4) in to latter put db_diagram.css, db_diagram_print.css, 
>>>> jquery.dbdiagram.js, pencildiagonals.png (an image create by me only for 
>>>> the css theme in bundle) (all these files are here attached)
>>>> 5) download jsPlumb (jQuery release) from 
>>>> http://code.google.com/p/jsplumb/downloads/list and put 
>>>> jquery.jsPlumb-1.3.16-all-min.js file in 
>>>> your_application/static/db_diagram 
>>>> folder
>>>>
>>>> Usage:
>>>> In your appadmin page you should see a new menu item "diagram" (see 
>>>> image 1), click on it and you should see the layout of your "db".
>>>>
>>>> That's all Folks!
>>>>
>>>

-- 

--- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to