Web2py YAML Model Translator

103 views
Skip to first unread message

Francisco Ribeiro

unread,
Apr 11, 2010, 8:37:47 AM4/11/10
to web...@googlegroups.com
hi

here is something I have done on web2py so you can define models using the YAML lang. I also included a 12 min screencast to show how you can use it: http://vimeo.com/10837176

checkout the template file in models/yaml/template.yml (inside the w2pymt.zip) for options
Please send me all comments, questions, critics but keep in mind this is little more than a proof of concept

Enjoy!
w2pymt.zip

blackthorne

unread,
Apr 11, 2010, 8:49:29 AM4/11/10
to web2py-users
For some reason the attachment didn't came up.
Here is the missing code: http://bit.ly/dgv8Qb

Best Regards

mdipierro

unread,
Apr 11, 2010, 10:19:39 AM4/11/10
to web2py-users
This is fantastic.
I think this should be integrated in web2py or at least provide a
plugin for it (assuming there is a pure python yaml parser with
compatible license and I think yes)

I also think, along this line there is even more we can do:

*) use the yaml also to define which actions are needed, which crud
forms and crud selects should be in each action, what their parameters
should be, which default layout to use (downloaded from web),
*) edit the yaml using a tree-like gui
*) save the state so that the yams stays attached to the generated app
*) Instead of generating code, provide an alternative scaffolding app
that generates models dynamically using the example in
http://groups.google.com/group/web2py/msg/97ebeff3781e6739

In the end the entire app can re presented as a tree:

- models
- db
- table 1
- field 1
- field 2
- type
- length
- validator
- widget
- widget attrbute
- table 2
- field 3
- controllers
- index:
- authentication: everybody
- show in menu: yes
- create form 1
- for table 1
- set field2 writable false
- select form 1
- filter records by query
- show only columns field 1, field 2
- view
- extends "http://...../web2py.plugin.sleek.w2p"
- h1: "Hello World"
- div
- p: "insert a record below"
- p
- place crud form
- h2:
- div
- p: "selected record"
- place crud select

blackthorne

unread,
Apr 11, 2010, 4:54:51 PM4/11/10
to web2py-users
Thank you,

yes, this is a little more than a proof of concept but my idea is to
extend it has needed. There could even be a "template manager" where
people could associate options with parts of the model to be included
(integrated with the web interface). To make things clear, I think a
good practice would be to define models in a yaml file, and model
methods, labels and helpers in a second python file (that would import
the generated code)...

one more thing:
I gave an option (not documented in the screencast) called "dbline".
Instead of defining a database with its variables explicitly, you can
just define the dbline directly, such as:
db:
name: db
dbline: mysql://username:password@localhost/test

Unfortunately (or not), I may take some time to answer in the next
week because I'll go for vacation to Sicily (have you heard of
it? ;)...

Best Regards

On Apr 11, 3:19 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> This is fantastic.
> I think this should be integrated in web2py or at least provide a
> plugin for it (assuming there is a pure python yaml parser with
> compatible license and I think yes)
>
> I also think, along this line there is even more we can do:
>
> *) use the yaml also to define which actions are needed, which crud
> forms and crud selects should be in each action, what their parameters
> should be, which default layout to use (downloaded from web),
> *) edit the yaml using a tree-like gui
> *) save the state so that the yams stays attached to the generated app
> *) Instead of generating code, provide an alternative scaffolding app

> that generates models dynamically using the example inhttp://groups.google.com/group/web2py/msg/97ebeff3781e6739

blackthorne

unread,
May 7, 2010, 9:44:03 AM5/7/10
to web2py-users
ok, next week I will try to make something out of this.
If anyone likes this idea and wants to suggest something, now is the
time.
Massimo, your idea is really interesting but probably requires some
kind of "sync", so that the user can change things in the HTML and see
it reflected in the YAML tree, you suggest. This seems fertile ground
to build/integrate a lot of things on top of it. Maybe I will divide
it in stages, I don't know...

Thanks,
Best regards

On Apr 11, 3:19 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> This is fantastic.
> I think this should be integrated in web2py or at least provide a
> plugin for it (assuming there is a pure pythonyamlparser with
> compatible license and I think yes)
>
> I also think, along this line there is even more we can do:
>
> *) use theyamlalso to define which actions are needed, which crud
> forms and crud selects should be in each action, what their parameters
> should be, which default layout to use (downloaded from web),
> *) edit theyamlusing a tree-like gui
> *) save the state so that the yams stays attached to the generated app
> *) Instead of generating code, provide an alternative scaffolding app
> that generates models dynamically using the example inhttp://groups.google.com/group/web2py/msg/97ebeff3781e6739
Reply all
Reply to author
Forward
0 new messages