Changeset 87
- Timestamp:
- 06/13/07 20:56:11
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
AuthKit/branches/0.4/authkit/authenticate/__init__.py
r83 r87 49 49 50 50 from authkit.authorize import authorize_request 51 from authkit.permissions import RemoteUser, no_authkit_users_in_environ, AuthKitConfigError 51 from authkit.permissions import RemoteUser, no_authkit_users_in_environ, \ 52 AuthKitConfigError 52 53 53 54 # Setting up logging … … 163 164 function = digest_password 164 165 else: 165 raise Exception('Invalid format for authenticate function %r'%format) 166 raise Exception('Invalid format for authenticate function %r' 167 % format) 166 168 return app, function, users 167 169 … … 190 192 (', '.join(template_conf.keys()))) 191 193 if template_conf.keys()[0] not in ['string', 'file', 'obj']: 192 raise AuthKitConfigError("Template option can only be 'string', 'file' or 'obj'") 194 raise AuthKitConfigError("Template option can only be 'string', 'file'" 195 " or 'obj'") 193 196 if template_conf.keys()[0] == 'string': 194 197 template = template_conf['string'] 195 198 elif template_conf.keys()[0] == 'file': 196 199 if not os.path.exists(template_conf['file']): 197 raise AuthKitConfigError( 198 'No such file %r exists. It was specified by config option %r'%( 199 template_conf['file'], 200 prefix+'file' 201 ) 202 ) 200 raise AuthKitConfigError('No such file %r exists. It was specified' 201 ' by config option %r' % 202 (template_conf['file'], prefix+'file')) 203 203 fp = open(template_conf['file'], 'r') 204 204 template = fp.read() 205 205 fp.close() 206 206 if not template: 207 raise AuthKitConfigError( 208 'No data in template file %s specified by config option %r'%( 209 template_conf['file'], 210 prefix+'file' 211 ) 212 ) 207 raise AuthKitConfigError('No data in template file %s specified by' 208 ' config option %r' % 209 (template_conf['file'], prefix+'file')) 213 210 elif template_conf.keys()[0] == 'obj': 214 211 template = eval_import(template_conf['obj']) 215 212 if not template: 216 raise AuthKitConfigError( 217 'No data in template obj %s specified by config option %r'%( 218 template_conf['obj'], 219 prefix+'obj' 220 ) 221 ) 213 raise AuthKitConfigError('No data in template obj %s specified by ' 214 'config option %r' % 215 (template_conf['obj'], prefix+'obj')) 222 216 else: 223 raise AuthKitConfigError("Unknown option %r"%(prefix+template_conf.keys()[0])) 217 raise AuthKitConfigError("Unknown option %r" % 218 (prefix+template_conf.keys()[0])) 224 219 if not template: 225 220 raise AuthKitConfigError("The template loaded did not contain any data") … … 265 260 self.key = key 266 261 self.missing_error = missing_error or \ 267 'Missing the key %(key)s from the environ. Have you setup the correct middleware?' 262 'Missing the key %(key)s from the environ. Have you setup the ' \ 263 'correct middleware?' 268 264 269 265 def __call__(self, environ, start_response): … … 305 301 handle_httpexception=True, **options): 306 302 """ 307 This function sets up the AuthKit authenticate middleware and its use and options308 are described in detail in the AuthKit manual.303 This function sets up the AuthKit authenticate middleware and its use and 304 options are described in detail in the AuthKit manual. 309 305 310 306 The function takes the following arguments and returns a WSGI application 311 wrapped in the appropriate AuthKit authentication middleware based on the options specified: 307 wrapped in the appropriate AuthKit authentication middleware based on the 308 options specified: 312 309 313 310 ``app`` … … 315 312 316 313 ``app_conf`` 317 A paste deploy ``app_conf`` dictionary to be used to setup the middleware 314 A paste deploy ``app_conf`` dictionary to be used to setup the 315 middleware 318 316 319 317 ``global_conf`` … … 322 320 ``config_file`` 323 321 The URI to a config file in the paste deploy format to be used to setup 324 the middleware. The URI is relative to the current working directory and325 should look something like ``config://dir/test.ini``. See the Paste Deploy326 documentation for more information.322 the middleware. The URI is relative to the current working directory 323 and should look something like ``config://dir/test.ini``. See the Paste 324 Deploy documentation for more information. 327 325 328 326 ``prefix`` … … 332 330 333 331 ``**options`` 334 Any AuthKit options which are setup directly in Python code. If specified, 335 these options will override any options specifed in a config file. 332 Any AuthKit options which are setup directly in Python code. If 333 specified, these options will override any options specifed in a config 334 file. 336 335 337 336 Only one of ``config_paste`` and ``config_file`` can be specified. All
