Changeset 5582

Show
Ignore:
Timestamp:
10/22/08 14:11:59 (3 months ago)
Author:
Gustavo
Message:
  • Changed the Identity message prompt in the quickstart.
  • Auth is now enabled by default in quickstarted projects.
  • Replaced identity by auth where it refered to the auth system (so it was not changed where it refered to repoze.who's identity dict).

Because tgext.authorization doesn't support Elixir, new projects may not use auth with it.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • projects/tg.devtools/branches/tgext.authorization/devtools/commands/quickstart.py

    r5355 r5582  
    2121    paster quickstart [--version][-h|--help] 
    2222            [-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
    2424 
    2525.. container:: paster-usage 
     
    3939  -e, --elixir 
    4040      use Elixir as ORM 
    41   -i, --identity 
    42       provide Identity support 
     41  -a, --auth 
     42      provide authentication and authorization support 
    4343""" 
    4444 
     
    8383    sqlobject = False 
    8484    elixir = False 
    85     identity = False 
     85    auth = False 
    8686 
    8787    parser = command.Command.standard_parser(quiet=True) 
     
    9595            help="use Elixir as ORM.", action="store_true", 
    9696            dest="elixir", default = False) 
    97     parser.add_option("-i", "--identity", 
    98             help="provide Identity support", 
    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) 
    100100    parser.add_option("-p", "--package", 
    101101            help="package name for the code", 
     
    140140                self.package = package 
    141141 
    142         doidentity = self.identity 
    143         while not doidentity
    144             doidentity = raw_input("Do you need Identity
    145                         "(usernames/passwords) in this project? [no] ") 
    146             doidentity = doidentity.lower() 
    147             if not doidentity or doidentity.startswith('n'): 
    148                 self.identity = Fals
     142        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 = Tru
    149149                break 
    150             if doidentity.startswith("y"): 
    151                 doidentity = Tru
     150            if doauth.startswith('n'): 
     151                self.auth = Fals
    152152                break 
    153153            print "Please enter y(es) or n(o)." 
    154             doidentity = None 
    155  
    156         if doidentity is 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" 
    159159            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" 
    161169 
    162170        self.name = pkg_resources.safe_name(self.name) 
     
    194202        cmd_args.append("elixir=%s" % self.elixir) 
    195203        cmd_args.append("sqlobject=%s" % self.sqlobject) 
    196         cmd_args.append("identity=%s" % self.identity
     204        cmd_args.append("auth=%s" % self.auth
    197205        cmd_args.append("package=%s" % self.package) 
    198206        cmd_args.append("tgversion=%s"%self.version) 
  • projects/tg.devtools/branches/tgext.authorization/devtools/templates/turbogears/+package+/config/app_cfg.py_tmpl

    r5166 r5582  
    2828{{endif}} 
    2929 
    30 {{if identity == "sqlalchemy"}} 
     30{{if auth == "sqlalchemy"}} 
    3131#Configure the authentication backend 
    3232base_config.auth_backend = 'sqlalchemy' 
  • projects/tg.devtools/branches/tgext.authorization/devtools/templates/turbogears/+package+/controllers/root.py_tmpl

    r4819 r5582  
    88#from dbsprockets.saprovider import SAProvider 
    99 
    10 {{if identity == "sqlalchemy"}} 
     10{{if auth == "sqlalchemy"}} 
    1111from tg.ext.repoze.who import authorize 
    1212from {{package}}.controllers.secc import Secc 
     
    1515class RootController(BaseController): 
    1616    #admin = DBMechanic(SAProvider(metadata), '/admin') 
    17     {{if identity == "sqlalchemy"}} 
     17    {{if auth == "sqlalchemy"}} 
    1818    secc = Secc() 
    1919    {{endif}} 
     
    2828 
    2929 
    30 {{if identity == "sqlalchemy"}} 
     30{{if auth == "sqlalchemy"}} 
    3131    @expose('{{package}}.templates.index') 
    3232    @authorize.require(authorize.has_permission('manage')) 
  • projects/tg.devtools/branches/tgext.authorization/devtools/templates/turbogears/+package+/controllers/secc.py_tmpl

    r4812 r5582  
    11"""Test Secure Controller""" 
    2 {{if identity == "sqlalchemy"}} 
     2{{if auth == "sqlalchemy"}} 
    33from {{package}}.lib.base import BaseController, SecureController 
    44from tg import expose, flash 
     
    2727        return dict() 
    2828{{else}} 
    29 # This controller is only used when you activate identity. You can safely remove 
     29# This controller is only used when you activate auth. You can safely remove 
    3030# this file from your project. 
    3131{{endif}} 
  • projects/tg.devtools/branches/tgext.authorization/devtools/templates/turbogears/+package+/lib/base.py_tmpl

    r5130 r5582  
    55from tg import TGController, tmpl_context 
    66from tg.render import render 
    7 {{if identity == "sqlalchemy"}} 
     7{{if auth == "sqlalchemy"}} 
    88from tg import request 
    99{{endif}} 
     
    3636        # available in environ['pylons.routes_dict'] 
    3737         
    38         {{if identity == "sqlalchemy"}} 
     38        {{if auth == "sqlalchemy"}} 
    3939        tmpl_context.identity = request.environ.get('repoze.who.identity') 
    4040        {{endif}} 
    4141        return TGController.__call__(self, environ, start_response) 
    4242 
    43 {{if identity == "sqlalchemy"}} 
     43{{if auth == "sqlalchemy"}} 
    4444class SecureController(BaseController): 
    4545    """this is a SecureController implementation for the 
  • projects/tg.devtools/branches/tgext.authorization/devtools/templates/turbogears/+package+/model/auth.py_tmpl

    r5540 r5582  
    1 {{if identity == "sqlalchemy"}} 
     1{{if auth == "sqlalchemy"}} 
    22{{if not elixir == "True"}} 
    33import md5 
     
    3232) 
    3333 
    34 # identity model 
     34# auth model 
    3535 
    3636class Group(DeclarativeBase): 
     
    135135        #elif "custom" == algorithm: 
    136136        #    custom_encryption_path = turbogears.config.get( 
    137         #        "identity.custom_encryption", None ) 
     137        #        "auth.custom_encryption", None ) 
    138138        # 
    139139        #    if custom_encryption_path: 
     
    153153    def get_encryption_method(self): 
    154154        """returns the encryption method from the config 
    155         If None is set, or identity is disabled this will return None 
    156         """ 
    157         identity_system = config.get('sa_auth', None) 
    158         if identity_system is None: 
    159             # if identity is not activated in the config we should warn 
     155        If None is set, or auth is disabled this will return None 
     156        """ 
     157        auth_system = config.get('sa_auth', None) 
     158        if auth_system is None: 
     159            # if auth is not activated in the config we should warn 
    160160            # the admin through the logs... and return None 
    161161            return None 
    162162 
    163         return identity_system.get('password_encryption_method', None) 
     163        return auth_system.get('password_encryption_method', None) 
    164164 
    165165    def validate_password(self, password): 
     
    301301        #elif "custom" == algorithm: 
    302302        #    custom_encryption_path = turbogears.config.get( 
    303         #        "identity.custom_encryption", None ) 
     303        #        "auth.custom_encryption", None ) 
    304304        # 
    305305        #    if custom_encryption_path: 
     
    319319    def get_encryption_method(self): 
    320320        """returns the encryption method from the config 
    321         If None is set, or identity is disabled this will return None 
    322         """ 
    323         identity_system = config.get('sa_auth', None) 
    324         if identity_system is None: 
    325             # if identity is not activated in the config we should warn 
     321        If None is set, or auth is disabled this will return None 
     322        """ 
     323        auth_system = config.get('sa_auth', None) 
     324        if auth_system is None: 
     325            # if auth is not activated in the config we should warn 
    326326            # the admin through the logs... and return None 
    327327            return None 
    328328 
    329         return identity_system.get('password_encryption_method', None) 
     329        return auth_system.get('password_encryption_method', None) 
    330330 
    331331    def validate_password(self, password): 
  • projects/tg.devtools/branches/tgext.authorization/devtools/templates/turbogears/+package+/model/__init__.py_tmpl

    r5354 r5582  
    7070# Import your model modules here. 
    7171 
    72 {{if identity == "sqlalchemy"}} 
    73 from identity import User, Group, Permission 
     72{{if auth == "sqlalchemy"}} 
     73from auth import User, Group, Permission 
    7474{{endif}} 
    7575 
  • projects/tg.devtools/branches/tgext.authorization/devtools/templates/turbogears/+package+/tests/test_models.py_tmpl

    r5358 r5582  
    1212 
    1313 
    14 {{if identity == "sqlalchemy"}} 
     14{{if auth == "sqlalchemy"}} 
    1515class TestUser(TestModel): 
    1616    """Test case for the User model.""" 
  • projects/tg.devtools/branches/tgext.authorization/devtools/templates/turbogears/+package+/websetup.py_tmpl

    r5130 r5582  
    2020    model.metadata.create_all(bind=config['pylons.app_globals'].sa_engine) 
    2121 
    22     {{if identity == "sqlalchemy"}} 
     22    {{if auth == "sqlalchemy"}} 
    2323    u = model.User() 
    2424    u.user_name = u'manager' 
  • projects/tg.devtools/branches/tgext.authorization/devtools/templates/turbogears/test.ini_tmpl

    r5358 r5582  
    1717 
    1818[app:main] 
    19 {{if identity == "sqlalchemy"}} 
     19{{if auth == "sqlalchemy"}} 
    2020sqlalchemy.url = sqlite:///:memory: 
    2121{{endif}} 
  • projects/tg.devtools/branches/tgext.authorization/devtools/tests/test_pastetemplate.py

    r5130 r5582  
    3131    command.args.append("sqlalchemy=%s"%True) 
    3232    command.args.append("sqlobject=%s"%False) 
    33     command.args.append("identity=%s"%False) 
     33    command.args.append("auth=%s"%False) 
    3434    print command 
    3535    command.templates = TurboGearsTemplate('TGTest')