Hey,
I tried py4web from github today on ubuntu 18.04 python 3.6.9.
Using the app scaffold creating a new app: works good
adding new fields in models, works ok: sometimes I get the error "table persons already exists". I only have that table persons. I need to restart.
Using Py4Web to create an create and update form works good. (Please keep the form/sqlform replacement around. Its great for protoyping and throw away apps. Being able to use Py4Web for prototype, trow away apps plus serious projects from one framework is great.
I usually replace the SQLFORM forms after protoyping with proper forms) I really love the form generator for CRUD.
I tested django-admlte2 and flask-appbuilder today for prototyping in case Py4Web deprecates SQLFORM, but noting is as good and quick as what you have done Massimo.
When I add the auth.user to the form the auth request ist not picked up.. I need to restart.
After the restart the get prompted to login or sign up.
So I sign up.
Desperately tried to disable email validation until I found the link in the console to validate a user. After I removing a superflous "/" in the URL in the console registration worked.
After logging in PY4Web crashes however:
ERROR:root:Traceback (most recent call last):
File "/home/ubuntu/Development/Python/DiPierro/py4web/py4web/core.py", line 473, in wrapper
ret = func(*func_args, **func_kwargs)
File "/home/ubuntu/Development/Python/DiPierro/py4web/py4web/core.py", line 441, in wrapper
ret = obj.transform(ret)
File "/home/ubuntu/Development/Python/DiPierro/py4web/py4web/core.py", line 253, in transform
delimiters=self.delimiters, reader=Template.reader)
File "/home/ubuntu/.local/share/virtualenvs/py4web-hAK7z7VI/lib/python3.6/site-packages/yatl/template.py", line 968, in render
exec(code, context)
File "<string>", line 23, in <module>
File "/home/ubuntu/.local/share/virtualenvs/py4web-hAK7z7VI/lib/python3.6/site-packages/yatl/template.py", line 831, in write
data = data.xml()
File "/home/ubuntu/.local/share/virtualenvs/py4web-hAK7z7VI/lib/python3.6/site-packages/yatl/helpers.py", line 52, in xml
for s in self.children)
File "/home/ubuntu/.local/share/virtualenvs/py4web-hAK7z7VI/lib/python3.6/site-packages/yatl/helpers.py", line 52, in <genexpr>
for s in self.children)
File "/home/ubuntu/.local/share/virtualenvs/py4web-hAK7z7VI/lib/python3.6/site-packages/yatl/helpers.py", line 52, in xml
for s in self.children)
File "/home/ubuntu/.local/share/virtualenvs/py4web-hAK7z7VI/lib/python3.6/site-packages/yatl/helpers.py", line 52, in <genexpr>
for s in self.children)
File "/home/ubuntu/.local/share/virtualenvs/py4web-hAK7z7VI/lib/python3.6/site-packages/yatl/helpers.py", line 52, in xml
for s in self.children)
File "/home/ubuntu/.local/share/virtualenvs/py4web-hAK7z7VI/lib/python3.6/site-packages/yatl/helpers.py", line 52, in <genexpr>
for s in self.children)
File "/home/ubuntu/.local/share/virtualenvs/py4web-hAK7z7VI/lib/python3.6/site-packages/yatl/helpers.py", line 52, in xml
for s in self.children)
File "/home/ubuntu/.local/share/virtualenvs/py4web-hAK7z7VI/lib/python3.6/site-packages/yatl/helpers.py", line 52, in <genexpr>
for s in self.children)
File "/home/ubuntu/.local/share/virtualenvs/py4web-hAK7z7VI/lib/python3.6/site-packages/yatl/helpers.py", line 52, in xml
for s in self.children)
File "/home/ubuntu/.local/share/virtualenvs/py4web-hAK7z7VI/lib/python3.6/site-packages/yatl/helpers.py", line 52, in <genexpr>
for s in self.children)
File "/home/ubuntu/.local/share/virtualenvs/py4web-hAK7z7VI/lib/python3.6/site-packages/yatl/helpers.py", line 52, in xml
for s in self.children)
File "/home/ubuntu/.local/share/virtualenvs/py4web-hAK7z7VI/lib/python3.6/site-packages/yatl/helpers.py", line 52, in <genexpr>
for s in self.children)
File "/home/ubuntu/.local/share/virtualenvs/py4web-hAK7z7VI/lib/python3.6/site-packages/yatl/helpers.py", line 52, in xml
for s in self.children)
File "/home/ubuntu/.local/share/virtualenvs/py4web-hAK7z7VI/lib/python3.6/site-packages/yatl/helpers.py", line 52, in <genexpr>
for s in self.children)
File "/home/ubuntu/.local/share/virtualenvs/py4web-hAK7z7VI/lib/python3.6/site-packages/yatl/helpers.py", line 52, in xml
for s in self.children)
TypeError: sequence item 0: expected str instance, int found
My code:
Models:
"""
This file defines the database models
"""
from . common import db, Field
from pydal.validators import *
### Define your table below
#
# db.define_table('thing', Field('name'))
#
## always commit your models to avoid problems later
#
# db.commit()
#
db.define_table(
'person',
Field('name', requires=IS_NOT_IN_DB(db, '
person.name')),
Field('job', requires=IS_NOT_EMPTY()))
db.commit()
Controllers:
from py4web import action, request, abort, redirect, URL
from yatl.helpers import A
from . common import db, session, T, cache, auth, logger
@action('index', method='GET')
@action.uses('generic.html', session, db, T, auth.user)
def index():
user = auth.get_user()
message = T('Hello {first_name}'.format(**user))
return dict(message=message, user=user)
@action('create_form', method=['GET','POST'])
@action('update_form/<id>', method=['GET','POST'])
@action.uses('generic.html', session, db, T, auth.user)
def example_form(id=None):
form = Form(db.person, id, deletable=False, formstyle=FormStyleBulma)
rows = db(db.person).select()
return dict(form=form, rows=rows)