Having a translation layer for different frameworks would be too much to maintain I think.
But if you could implement a way that some defaults can be easily overrriden, where it makes sense.. that would be great. What that means will be a bit different from module to module I suppose, but for the case of Form. Py which will eventually generate its own submit/post requesr route, an easy way to change the standard post url would make it easy to adapt it form.py for different frameworks. On Sun, 14 Apr 2019, 16:57 Massimo Di Pierro, <massimo.dipie...@gmail.com> wrote: > I would be happy to keep the logic in form.py and other upcoming modules > framework agnostic. If you have ideas about how to best do that, please let > me know > > On Saturday, 13 April 2019 10:03:49 UTC-7, Kevin Keller wrote: >> >> Changing the import headers of form.py from web3py like this: >> >> import uuid >> import hmac >> from pydal import DAL >> from flask import request >> from yatl.helpers import A, TEXTAREA, INPUT, TR, TD, TABLE, DIV, LABEL, >> FORM >> from pydal._compat import to_bytes >> >> >> and with the rest of the sample code like this: >> >> from flask import Flask >> from yatl import render, SPAN >> from form import Form >> app = Flask(__name__) >> >> from pydal import DAL, Field >> db = DAL('sqlite://storage.db') >> db.define_table('thing', Field('name')) >> db.thing.insert(name='Chair') >> query = db.thing.name.startswith('C') >> db.commit() >> >> >> @app.route('/') >> def hello(): >> db._adapter.reconnect() >> rows = db(query).select() >> db._adapter.close() >> form = Form(db.thing) >> example = """ >> <div> >> <h1> hello! {{=rows[0].name}} </h1> >> {{=form}} >> {{ pass }} >> </div> >> """ >> print (rows[0].name) >> return render(example,context={'rows':rows,'form':form}, >> delimiters="{{ }}") >> >> app.run(host='0.0.0.0',use_reloader=False) >> >> The Form is rendered correctly. >> >> The action URL only would need an overriding option and one would also >> need to define a POST route. >> >> Then it should work. >> >> Was fun playing with it.. so far it seems the work you do with bottle is >> easily transferrable to Flask or Pyramid as well with minor modifications.. >> >> >> >> >> >> On Sat, Apr 13, 2019 at 6:25 PM Kevin Keller <keller...@gmail.com> wrote: >> >>> Ok got it.. just forgot to actually use yatl right... >>> >>> from flask import Flask >>> from yatl import render, SPAN >>> app = Flask(__name__) >>> >>> from pydal import DAL, Field >>> db = DAL('sqlite://storage.db') >>> db.define_table('thing', Field('name')) >>> db.thing.insert(name='Chair') >>> query = db.thing.name.startswith('C') >>> db.commit() >>> >>> >>> @app.route('/') >>> def hello(): >>> db._adapter.reconnect() >>> rows = db(query).select() >>> db._adapter.close() >>> example = """ >>> <div> >>> <h1> hello! {{=rows[0].name}} </h1> >>> {{ pass }} >>> </div> >>> """ >>> print (rows[0].name) >>> return render(example,context={'rows':rows}, delimiters="{{ }}") >>> >>> app.run(host='0.0.0.0',use_reloader=False) >>> >>> >>> >>> On Sat, Apr 13, 2019 at 6:06 PM Kevin Keller <keller...@gmail.com> >>> wrote: >>> >>>> return render(example,context={'rows':rows}, delimiters="{{ }}") >>>> >>>> Also does not work.. >>>> >>>> On Sat, Apr 13, 2019 at 5:47 PM Kevin Keller <keller...@gmail.com> >>>> wrote: >>>> >>>>> I only get the h1 Hello World in the browser, but I struggle to pass >>>>> over values to the templates with yatl >>>>> >>>>> is context=(rows=rows) the correct way? >>>>> >>>>> See the last return statement. >>>>> >>>>> The print command outputs "Chair" as expected. >>>>> >>>>> The HTML file should output >>>>> >>>>> Hello! Chair >>>>> >>>>> >>>>> >>>>> from flask import Flask >>>>> from yatl import render, SPAN >>>>> app = Flask(__name__) >>>>> >>>>> from pydal import DAL, Field >>>>> db = DAL('sqlite://storage.db') >>>>> db.define_table('thing', Field('name')) >>>>> db.thing.insert(name='Chair') >>>>> query = db.thing.name.startswith('C') >>>>> db.commit() >>>>> >>>>> >>>>> @app.route('/') >>>>> def hello(): >>>>> db._adapter.reconnect() >>>>> rows = db(query).select() >>>>> db._adapter.close() >>>>> example = """ >>>>> <div> >>>>> <h1> hello! {{rows[0].name}} </h1> >>>>> {{ pass }} >>>>> </div> >>>>> """ >>>>> print (rows[0].name) >>>>> return render(example,context=dict(rows=rows), delimiters="{{ }}") >>>>> >>>>> app.run(host='0.0.0.0',use_reloader=False) >>>>> >>>>> -- >>>>> Resources: >>>>> - http://web2py.com >>>>> - http://web2py.com/book (Documentation) >>>>> - http://github.com/web2py/web2py (Source code) >>>>> - https://code.google.com/p/web2py/issues/list (Report Issues) >>>>> --- >>>>> 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/d/optout. >>>>> >>>> -- > Resources: > - http://web2py.com > - http://web2py.com/book (Documentation) > - http://github.com/web2py/web2py (Source code) > - https://code.google.com/p/web2py/issues/list (Report Issues) > --- > 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/d/optout. > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.