[web2py] Re: Creating a 5 page PDF file to teach web2py -- What should I focus on?

2014-08-02 Thread Matheus Cardoso
It could be a good ideia to create a github repository to allow the 
community collaborates with you. Then, you can control this by issues and, 
who knows, accept some pull requests. 

On Thursday, July 31, 2014 11:05:59 PM UTC-3, LoveWeb2py wrote:

 Hello,

 I'm creating a 5 page PDF to get users acquainted with web2py. I'd like to 
 orientate them with the MVC model, have them define a database, and create 
 a simple app.

 I could add an extra page if needed, but do you think there is a better 
 topic I could focus on other than what I have listed? I'm totally open to 
 input and will share the presentation when complete :)

 Everyone here has helped me so much in the past so I truly value and 
 appreciate your input.



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


[web2py] Re: Creating a 5 page PDF file to teach web2py -- What should I focus on?

2014-08-01 Thread Bilal Hasan
Creating and processing SQLFORMs, python code in views, setting up tables 
in models, html helper tags, and lets see. Access control on functions such 
as @auth.requires() on top of a function etc.

On Thursday, July 31, 2014 9:05:59 PM UTC-5, LoveWeb2py wrote:

 Hello,

 I'm creating a 5 page PDF to get users acquainted with web2py. I'd like to 
 orientate them with the MVC model, have them define a database, and create 
 a simple app.

 I could add an extra page if needed, but do you think there is a better 
 topic I could focus on other than what I have listed? I'm totally open to 
 input and will share the presentation when complete :)

 Everyone here has helped me so much in the past so I truly value and 
 appreciate your input.



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


[web2py] Re: Creating a 5 page PDF file to teach web2py -- What should I focus on?

2014-07-31 Thread 黄祥
just a suggestion :
in models : database uri, database migration, lazy tables, define table, 
web2py built in menu
in controllers : import the module, using grid
in views : extend layout, and the variable return by controller

e.g. very easy n simple application (not more than 100 lines)
*models/db.py*
db = DAL('sqlite://shop.sqlite', pool_size = 30, check_reserved = ['all'], 
 migrate = True, fake_migrate_all = False, lazy_tables = True)

*models/db_wizard_0_bank.py*
db.define_table('bank', 
Field('name'),
auth.signature,
format = '%(name)s')

*models/menu.py*
if auth.has_membership(role = 'Finance'):
response.menu += [
(T('Finance'), False, URL('default', 'index'), [
(T('Master'), False, URL('finance_master', 'index'), [
(T('Bank'), False, URL('finance_master', 'bank'), []),
]),
]), 
]

*controllers/finance_master.py*
import master

auth.requires(auth.has_membership(role = 'Finance'))(lambda: None)()

has_membership_manager = auth.has_membership('Manager')

editable = has_membership_manager
deletable = has_membership_manager

def bank():
return master.grid_0(db.bank, editable, deletable)
  
*controllers/install.py*
def index():
if db(db.auth_permission).isempty() and 
db(db.auth_membership).isempty():
 create index 
db.executesql('CREATE INDEX idx_bank ON bank (id, name);')

 insert 
# group
auth.add_group('Admin', 'Admin')
auth.add_group('Manager', 'Manager')
auth.add_group('Finance', 'Finance')

# user
db.auth_user.bulk_insert([{first_name : Admin, last_name : 
Admin, 
   email : ad...@a.com, 
   password : 
db.auth_user.password.validate(password)[0]}, 
  {first_name : Finance, last_name : 
Manager, 
   email : financemana...@a.com, 
   password : 
db.auth_user.password.validate(password)[0]}, 
  {first_name : Finance, last_name : 
Staff, 
   email : financest...@a.com, 
   password : 
db.auth_user.password.validate(password)[0]}, ])


membership (group_id, user_id)

# Admin
auth.add_membership('1', '1')
auth.add_membership('2', '1')
auth.add_membership('3', '1')
auth.add_membership('4', '1')
# Finance Manager
auth.add_membership('2', '2')
auth.add_membership('3', '2')
# Finance Staff
auth.add_membership('3', '3')

# permission
auth.add_permission(1, 'impersonate', 'auth_user', 2)
auth.add_permission(1, 'impersonate', 'auth_user', 3)

 insert 0 
# bank
db.bank.bulk_insert([{name : A}, 
 {name : B}, ])

session.flash = T('Installation Done')
redirect(URL(default, index) )

*modules/master.py*
from gluon import *

def grid_0(table, editable, deletable):
grid = SQLFORM.grid(table, editable = editable, deletable = deletable)
return locals()

*views/finance_master/bank.html*
{{extend 'layout.html'}}

{{=grid}}

best regards,
stifan

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