It may be not directly related to this topic, but I have been thinking 
about this for a long time now:
Writing database schemas in python in the model is very simple and 
decorative.
Why not make it a declarative format?
This way, it can be designed and updated with this kind of GUI tooling, as 
a 2-way binding.
This can even be layered on-top of the currently existing pythonic-way of 
writing it, using a simple parser.
It's just a matter of choosing a declarative format/protocol - preferably 
something SQL-related and open standard.
I am unfamiliar with this field, but I am sure there are many such formats 
that already exist.
This way, the schema can even be edited in whatever other external tool 
that supports that format.

Just as an example, a GUI graphical designer could produce something like:
"
<--! db.xml -->
<database name="MyDatabase" port="5432" type="postgres" user="postgres" 
host="myhost">
  <table name="MyTable">
    <field name="MyField" type="string">
  </table>
</database>
"

And then this can be used in the model as such:
"
...
# prepare a 'databases' list from the xml document that was parsed
...
for database in databases:
  db = DAL()
  ...
  # prepare a 'tables' list from the 'database' node's children...
  ...
  for table in tables:
    fields = []
    ...
    # prepare a 'tableFields' list from the 'table' node's children...
    ...
    for tableField in tableFfields:
      ...
      # convert the tableFiled node into a dictionary with it's attributes
      ...
      field = db.defineField( tableField['Name'], tableFiled[''type'] )
      fields.append(field)

   db.defineTable(table['name'], fields)
"

This can be further integrated into the DAL class itself, of course...

-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to