In web3py an application is a folder, for example "myapp". It must have:

applications/
  myapp/
    __init__.py
    templates/
    static/
    databases/

otherwise the structure is free. You are free to create models/ and 
controllers/ and organize code like in the old web2py but the entry point 
is __init__.py. Web3py will see functions defined in __init_ or imported by 
init. In my examples I defined all actions in __init__. For example

In __init__.py =============
from . import models
from . import controllers

In model.py =============
from web3py import DAL, Field
db = DAL('sqlite://test')
db.define_table('thing', Field('name'))

In controllers.py =============
from web3py import action, request, redirect, abort
from . models import db
@action('helloworld') # exposes http://127.0.0.1:8000/myapp/helloworld
@action.uses(db, 'helloworld.html')
def helloworld(): return dict(name=request.forms.get('name', 'visitor'))

In templates/helloworld.html =============
[[extend 'layout.html']]
<h1>Hello Dear [[=name]]</h1>

In templates/layout.html =============
<html><body>[[include]]</body></html>


request, redirect, abort are Bottely objects
DAL, Field are web2py's
the template is the same as web2py but defaults to [[ ]] delimiters to 
avoid conflicts with vue.js and other js
the @action decorator accepts the same parameters as bottle.route but does 
a little more.
There is also a form.py that implements Form() a drop in replacement (to be 
tested) for SQLFORM.

Notice we do all of this in 300 lines of python code and 10x faster than 
web2py in my tests.

Working on admin and appadmin. May be done in one week.

Massimo





On Friday, 12 April 2019 06:53:57 UTC-7, En Ware wrote:
>
> I'm trying to wrap my ahead around how web3py works by looking at the 
> source 
>
> I see __init__.py is the main code for the actually todo app. 
>
> Is this going to be the case for all applications ? or is this just for a 
> sample ? 
>
>
> On Thursday, April 11, 2019 at 11:03:29 PM UTC-5, Massimo Di Pierro wrote:
>>
>> There is a lot to do but at this point it is moving fast and a one way 
>> street.
>>
>> On Thursday, 11 April 2019 10:31:29 UTC-7, En Ware wrote:
>>>
>>> I git installed web3py and quite enjoy it. I see its updated regular 
>>> too. 
>>>
>>> For those who don't know and maybe this is common sense , not sure. 
>>>
>>> once you *git clone https://github.com/web2py/web3py.git 
>>> <https://github.com/web2py/web3py.git>  *do a *git pull*
>>>
>>> 2. reinstall requirements.txt (*pip3 install -r requirements.txt*) 
>>>  - Changes:  module "reloader" was added 
>>>
>>> 3. Launch web3py (should work just fine now) 
>>>
>>> * python3 web3py.py applications/todo/*
>>>
>>> 4. open browser and type: * localhost:8000 or 127.0.0.1:8000 
>>> <http://127.0.0.1:8000>/todo/index*
>>>
>>>

-- 
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.

Reply via email to