Hello community, after few months I'm happy to announce that new version of SQL WWW Developer is possible to integrate into web2py without need to patch web2py nor www sql designer code. Attached files in web2py-backend.tar.gz should replace default files in wwwsqldesigner-2.3.3.zip<http://wwwsqldesigner.googlecode.com/files/wwwsqldesigner-2.3.3.zip> in folder <unpacked_wwwsqldesigner>/db/web2py. Process of integration into web2py is following:
1. Download web2py <http://web2py.com/examples/static/web2py_src.zip> and unpack (doh) 2. create application named designer for example (no hard-coding of names needed anymore) 3. change dir to <application_name>/static/ 4. Download and unpack wwwsqldesigner-2.3.3.zip and rename folder to designer ( that is needed if you don't want to change default.py code) 5. cd designer/db/web2py and unpack web2py-backend.tar.gz file from this email. 6. cd designer/js/ and edit it so it looks like this snipper bellow --------------------------------------------------------------------------------------------------------- var CONFIG = { AVAILABLE_DBS:["mysql","sqlite","web2py","mssql","postgresql"], DEFAULT_DB:"*web2py*", AVAILABLE_LOCALES:["en","fr","de","cs","pl","pt_BR","es", "ru","eo"], DEFAULT_LOCALE:"en", AVAILABLE_BACKENDS:["php-mysql","php-blank","php-file","php-sqlite","* web2py*"], DEFAULT_BACKEND:["*web2py*"], RELATION_THICKNESS:2, RELATION_SPACING:15, STATIC_PATH: "", XHR_PATH: "*../../default/*" } --------------------------------------------------------------------------------------------------------- 7. edit ( from web gui or from console ) *models/db.py* and add table definition: --------------------------------------------------------------------------------------------------------- db.define_table("tbldata", Field("tblname", "string", default="tabela"), Field("changed", "datetime", default=request.now), Field("xmldata", "blob")) --------------------------------------------------------------------------------------------------------- 8. replace *controllers/default.py* with code attached ( default.py) - adding backend for web2py and redirection to static/designer/index.html 9a. Go to http://<YOUR_IP>/<appname>/ and enjoy creating tables visually 9b. Buy beer or some cocktail to me when in Belgrade, Serbia :) (and to Ondrej as he created this great tool) FIXES: data types fixes (removal of timestamp), many XSL fixes; - relations are working now as they should - no need to remove anything from "relations" line if you are lazy it should just work :), - tables without relation will be first on list of created tables as needed by web2py - when this is not a case web2py will error out. - password fields will not be mapped to select box by design!! - some defaults are mapped correctly - still watch out for single quotes! Boris Manojlovic -- "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."-Albert Einstein --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---
web2py-backend.tar.gz
Description: GNU Zip compressed data
# coding: utf8
#########################################################################
## This is a samples controller
## - index is the default action of any application
## - user is required for authentication and authorization
## - download is for downloading files uploaded in the db (does streaming)
## - call exposes all registered services (none by default)
#########################################################################
def index():
"""
example action using the internationalization operator T and flash
rendered by views/default/index.html or views/generic.html
"""
redirect(URL(r=request,c='static',f='designer/index.html'))
def user():
"""
exposes:
http://..../[app]/default/user/login
http://..../[app]/default/user/logout
http://..../[app]/default/user/register
http://..../[app]/default/user/profile
http://..../[app]/default/user/retrieve_password
http://..../[app]/default/user/change_password
use @auth.requires_login()
@auth.requires_membership('group name')
@auth.requires_permission('read','table name',record_id)
to decorate functions that need access control
"""
return dict(form=auth())
def download():
"""
allows downloading of uploaded files
http://..../[app]/default/download/[filename]
"""
return response.download(request,db)
def call():
"""
exposes services. for example:
http://..../[app]/default/call/jsonrpc
decorate with @services.jsonrpc the functions to expose
supports xml, json, xmlrpc, jsonrpc, amfrpc, rss, csv
"""
session.forget()
return service()
def backend():
import re
if request.vars.action == "save": # api is URL?action=save&keyword=schemaname
if re.compile('[^0-9a-zA-Z]').findall(request.vars.keyword):
raise HTTP(503, 'NOT SAVED! use [0-9a-zA-Z] for project names only... ')
name = db(db.tbldata.tblname == request.vars.keyword).select(db.tbldata.tblname)
if len(name) != 0:
db(db.tbldata.tblname==request.vars.keyword).update(
tblname=request.vars.keyword,
changed=request.now,
xmldata=request.body.read()
)
else:
db.tbldata.insert(tblname=request.vars.keyword,
changed=request.now,
xmldata=request.body.read()
)
raise HTTP(201, "Model has been saved...")
#request.body.read()
elif request.vars.action == "list": # api is URL?action=list
rows = db().select(db.tbldata.ALL)
names = ""
for row in rows:
if names == "":
names = row.tblname
continue
names = names + "\n" + row.tblname
response.headers['Content-Type'] = 'text/plain'
return names
elif request.vars.action == "load": # api is URL?action=load&keyword=schemaname
row = db(db.tbldata.tblname == request.vars.keyword).select(db.tbldata.xmldata)
if len(row) != 0 :
response.headers['Content-Type'] = 'application/xml'
return row[0].xmldata
else:
raise HTTP(404,T('Model Not found...'))
elif request.vars.action == "import": # api is URL?action=import&database=somedatabasename
raise HTTP(501,T("Not implemented"))

