Changeset 5599
- Timestamp:
- 10/24/08 12:47:35 (3 months ago)
- Files:
-
- projects/tg.devtools/trunk/devtools/commands/quickstart.py (modified) (6 diffs)
- projects/tg.devtools/trunk/devtools/templates/turbogears/+package+/config/app_cfg.py_tmpl (modified) (1 diff)
- projects/tg.devtools/trunk/devtools/templates/turbogears/+package+/controllers/root.py_tmpl (modified) (3 diffs)
- projects/tg.devtools/trunk/devtools/templates/turbogears/+package+/controllers/secc.py_tmpl (modified) (3 diffs)
- projects/tg.devtools/trunk/devtools/templates/turbogears/+package+/lib/base.py_tmpl (modified) (2 diffs)
- projects/tg.devtools/trunk/devtools/templates/turbogears/+package+/model/auth.py_tmpl (copied) (copied from projects/tg.devtools/branches/tgext.authorization/devtools/templates/turbogears/+package+/model/auth.py_tmpl)
- projects/tg.devtools/trunk/devtools/templates/turbogears/+package+/model/identity.py_tmpl (deleted)
- projects/tg.devtools/trunk/devtools/templates/turbogears/+package+/model/__init__.py_tmpl (modified) (1 diff)
- projects/tg.devtools/trunk/devtools/templates/turbogears/+package+/tests/test_models.py_tmpl (modified) (1 diff)
- projects/tg.devtools/trunk/devtools/templates/turbogears/+package+/websetup.py_tmpl (modified) (1 diff)
- projects/tg.devtools/trunk/devtools/templates/turbogears/test.ini_tmpl (modified) (1 diff)
- projects/tg.devtools/trunk/devtools/tests/test_pastetemplate.py (modified) (1 diff)
- projects/tg.devtools/trunk/setup.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
projects/tg.devtools/trunk/devtools/commands/quickstart.py
r5355 r5599 21 21 paster quickstart [--version][-h|--help] 22 22 [-p *PACKAGE*][--dry-run][-t|--templates *TEMPLATES*] 23 [-s|--sqlalchemy][-o|--sqlobject][-e|--elixir][- i|--identity]23 [-s|--sqlalchemy][-o|--sqlobject][-e|--elixir][-a|--auth] 24 24 25 25 .. container:: paster-usage … … 39 39 -e, --elixir 40 40 use Elixir as ORM 41 - i, --identity42 provide Identitysupport41 -a, --auth 42 provide authentication and authorization support 43 43 """ 44 44 … … 83 83 sqlobject = False 84 84 elixir = False 85 identity= False85 auth = False 86 86 87 87 parser = command.Command.standard_parser(quiet=True) … … 95 95 help="use Elixir as ORM.", action="store_true", 96 96 dest="elixir", default = False) 97 parser.add_option("- i", "--identity",98 help="provide Identitysupport",99 action="store_true", dest=" identity", default = False)97 parser.add_option("-a", "--auth", 98 help="provide authentication and authorization support", 99 action="store_true", dest="auth", default = True) 100 100 parser.add_option("-p", "--package", 101 101 help="package name for the code", … … 140 140 self.package = package 141 141 142 do identity = self.identity143 while not do identity:144 do identity = raw_input("Do you need Identity"145 "(usernames/passwords) in this project? [no] ")146 do identity = doidentity.lower()147 if not do identity or doidentity.startswith('n'):148 self.identity = False142 doauth = self.auth 143 while not doauth: 144 doauth = raw_input("Do you need authentication and authorization " 145 "in this project? [yes] ") 146 doauth = doauth.lower() 147 if not doauth or doauth.startswith("y"): 148 doauth = True 149 149 break 150 if do identity.startswith("y"):151 doidentity = True150 if doauth.startswith('n'): 151 self.auth = False 152 152 break 153 153 print "Please enter y(es) or n(o)." 154 do identity= None155 156 if do identityis True:157 if self.sqlalchemy :158 self. identity= "sqlalchemy"154 doauth = None 155 156 if doauth is True: 157 if self.sqlalchemy and not self.elixir: 158 self.auth = "sqlalchemy" 159 159 else: 160 self.identity = "sqlobject" 160 print 'You can only use authentication and authorization ' \ 161 'in a new project if you use SQLAlchemy. Please check ' \ 162 'the documentation of tgext.authorization to learn ' \ 163 'how to implement authentication/authorization with ' \ 164 'other sources.' 165 return 166 # TODO: As far as I know, SQLObject has never been supported in 167 # TG2 168 # self.auth = "sqlobject" 161 169 162 170 self.name = pkg_resources.safe_name(self.name) … … 194 202 cmd_args.append("elixir=%s" % self.elixir) 195 203 cmd_args.append("sqlobject=%s" % self.sqlobject) 196 cmd_args.append(" identity=%s" % self.identity)204 cmd_args.append("auth=%s" % self.auth) 197 205 cmd_args.append("package=%s" % self.package) 198 206 cmd_args.append("tgversion=%s"%self.version) projects/tg.devtools/trunk/devtools/templates/turbogears/+package+/config/app_cfg.py_tmpl
r5166 r5599 28 28 {{endif}} 29 29 30 {{if identity== "sqlalchemy"}}31 # Configure the authentication backend30 {{if auth == "sqlalchemy"}} 31 # Configure the authentication backend 32 32 base_config.auth_backend = 'sqlalchemy' 33 base_config.sa_auth = Bunch()34 33 base_config.sa_auth.dbsession = model.DBSession 35 34 base_config.sa_auth.user_class = model.User 36 35 base_config.sa_auth.group_class = model.Group 37 36 base_config.sa_auth.permission_class = model.Permission 38 base_config.sa_auth.user_criterion = model.User.user_name39 base_config.sa_auth.user_id_column = 'user_id'40 37 41 38 # override this if you would like to provide a different who plugin for projects/tg.devtools/trunk/devtools/templates/turbogears/+package+/controllers/root.py_tmpl
r4819 r5599 8 8 #from dbsprockets.saprovider import SAProvider 9 9 10 {{if identity== "sqlalchemy"}}11 from tg .ext.repoze.whoimport authorize10 {{if auth == "sqlalchemy"}} 11 from tgext.authorization import authorize 12 12 from {{package}}.controllers.secc import Secc 13 13 {{endif}} … … 15 15 class RootController(BaseController): 16 16 #admin = DBMechanic(SAProvider(metadata), '/admin') 17 {{if identity== "sqlalchemy"}}17 {{if auth == "sqlalchemy"}} 18 18 secc = Secc() 19 19 {{endif}} … … 28 28 29 29 30 {{if identity== "sqlalchemy"}}30 {{if auth == "sqlalchemy"}} 31 31 @expose('{{package}}.templates.index') 32 32 @authorize.require(authorize.has_permission('manage')) projects/tg.devtools/trunk/devtools/templates/turbogears/+package+/controllers/secc.py_tmpl
r4812 r5599 1 1 """Test Secure Controller""" 2 {{if identity== "sqlalchemy"}}2 {{if auth == "sqlalchemy"}} 3 3 from {{package}}.lib.base import BaseController, SecureController 4 4 from tg import expose, flash … … 8 8 #from dbsprockets.dbmechanic.frameworks.tg2 import DBMechanic 9 9 #from dbsprockets.saprovider import SAProvider 10 from tg .ext.repoze.whoimport authorize10 from tgext.authorization import authorize 11 11 12 12 … … 27 27 return dict() 28 28 {{else}} 29 # This controller is only used when you activate identity. You can safely remove29 # This controller is only used when you activate auth. You can safely remove 30 30 # this file from your project. 31 31 {{endif}} projects/tg.devtools/trunk/devtools/templates/turbogears/+package+/lib/base.py_tmpl
r5130 r5599 5 5 from tg import TGController, tmpl_context 6 6 from tg.render import render 7 {{if identity== "sqlalchemy"}}7 {{if auth == "sqlalchemy"}} 8 8 from tg import request 9 9 {{endif}} … … 36 36 # available in environ['pylons.routes_dict'] 37 37 38 {{if identity== "sqlalchemy"}}38 {{if auth == "sqlalchemy"}} 39 39 tmpl_context.identity = request.environ.get('repoze.who.identity') 40 40 {{endif}} 41 41 return TGController.__call__(self, environ, start_response) 42 42 43 {{if identity== "sqlalchemy"}}43 {{if auth == "sqlalchemy"}} 44 44 class SecureController(BaseController): 45 """ this is a SecureController implementation for the46 tg.ext.repoze.who plugin.45 """SecureController implementation for the tgext.authorization extension. 46 47 47 it will permit to protect whole controllers with a single predicate 48 48 placed at the controller level. projects/tg.devtools/trunk/devtools/templates/turbogears/+package+/model/__init__.py_tmpl
r5354 r5599 70 70 # Import your model modules here. 71 71 72 {{if identity== "sqlalchemy"}}73 from identityimport User, Group, Permission72 {{if auth == "sqlalchemy"}} 73 from auth import User, Group, Permission 74 74 {{endif}} 75 75 projects/tg.devtools/trunk/devtools/templates/turbogears/+package+/tests/test_models.py_tmpl
r5358 r5599 12 12 13 13 14 {{if identity== "sqlalchemy"}}14 {{if auth == "sqlalchemy"}} 15 15 class TestUser(TestModel): 16 16 """Test case for the User model.""" projects/tg.devtools/trunk/devtools/templates/turbogears/+package+/websetup.py_tmpl
r5130 r5599 20 20 model.metadata.create_all(bind=config['pylons.app_globals'].sa_engine) 21 21 22 {{if identity== "sqlalchemy"}}22 {{if auth == "sqlalchemy"}} 23 23 u = model.User() 24 24 u.user_name = u'manager' projects/tg.devtools/trunk/devtools/templates/turbogears/test.ini_tmpl
r5358 r5599 17 17 18 18 [app:main] 19 {{if identity== "sqlalchemy"}}19 {{if auth == "sqlalchemy"}} 20 20 sqlalchemy.url = sqlite:///:memory: 21 21 {{endif}} projects/tg.devtools/trunk/devtools/tests/test_pastetemplate.py
r5130 r5599 31 31 command.args.append("sqlalchemy=%s"%True) 32 32 command.args.append("sqlobject=%s"%False) 33 command.args.append(" identity=%s"%False)33 command.args.append("auth=%s"%False) 34 34 print command 35 35 command.templates = TurboGearsTemplate('TGTest') projects/tg.devtools/trunk/setup.py
r5319 r5599 28 28 'tw.forms>=0.9', 29 29 'DBSprockets >=0.5dev-r380', 30 'tg .ext.repoze.who',30 'tgext.authorization', 31 31 'TurboJson>=1.2', 32 32 'wsgiref==0.1.2',