def checkNewRegistration(self, user): content = "" player_name = self.request.get("player_name") player_age = self.request.get("player_age") if helpers.validateName(player_name) is False: content = """ <div id="fail_message"><h3>Trouble! Your player name has some issues.<h3></div> """ if self.checkAlreadyExists(player_name): content = ( content + """ <div id="fail_message"><h3>Dadgum it! Someone already took that name.<h3></div> """ ) if not helpers.is_number(player_age): content = ( content + """ <div id="fail_message"><h3>It appears you didn't enter a valid number for your age. You do know your age, don't you?<h3></div> """ ) else: player_age = int(player_age) if player_age < 13 or player_age > 135: content = ( content + """ <div id="fail_message"><h3>Your age is outside the valid range. Either you're too young or you're impossibly old.<h3></div> """ ) if content != "": content = content + '<div><a href="/"><h3>Click here to return and try again.<h3></a></div>' return content
def __init__(self, Underlying, Config): __ec_member__ = getattr(Underlying, '__ec_member__', None) if 'name' in Config: validateName(Config['name']) else: Config['name'] = getattr(Underlying, 'func_name', Underlying.__name__).rsplit('.', 1)[-1] if __ec_member__: __ec_member__.Config.update(Config) self.Config = __ec_member__.Config else: Underlying.__ec_member__ = self self.Config = Config self.Underlying = Underlying
def __load_args__(self, Args): r"""Prepares the task for excecution. """ FuncArgs = _getFuncArgs(self.Underlying) OrderedArgs = OrderedDict( ) # Note: the order of configuration (through decorators) is prefered over the order of declaration (within the function body) for Arg in Args: argName = Arg.get('name') if argName is None: if not FuncArgs: raise HandledException( 'Excess args while configuring "%s".' % self.Config['name']) FuncArg = FuncArgs.iteritems().next() # get the next free arg argName = FuncArg[0] FuncArg = FuncArg[1] else: validateName(argName) FuncArg = FuncArgs.get(argName) if FuncArg is None: raise HandledException( 'Unknown arg "%s" while configuring "%s".' % (argName, self.Config['name'])) FuncArg['name'] = argName FuncArg.update( Arg ) # prefer Args config over the values given while defining the function. OrderedArgs[argName] = self.__config_arg__(FuncArg) del FuncArgs[argName] for name, Config in FuncArgs.iteritems( ): # process the unconfigured arguments Config['name'] = name OrderedArgs[name] = self.__config_arg__(Config) return OrderedArgs
def __load_args__(self, Args): r"""Prepares the task for excecution. """ FuncArgs = _getFuncArgs(self.Underlying) OrderedArgs = OrderedDict() # Note: the order of configuration (through decorators) is prefered over the order of declaration (within the function body) for Arg in Args: argName = Arg.get('name') if argName is None: if not FuncArgs: raise HandledException('Excess args while configuring "%s".' % self.Config['name']) FuncArg = FuncArgs.iteritems().next() # get the next free arg argName = FuncArg[0] FuncArg = FuncArg[1] else: validateName(argName) FuncArg = FuncArgs.get(argName) if FuncArg is None: raise HandledException('Unknown arg "%s" while configuring "%s".' % (argName, self.Config['name'])) FuncArg['name'] = argName FuncArg.update(Arg) # prefer Args config over the values given while defining the function. OrderedArgs[argName] = reconfigArg(FuncArg) del FuncArgs[argName] for name, Config in FuncArgs.iteritems(): # process the unconfigured arguments Config['name'] = name OrderedArgs[name] = reconfigArg(Config) return OrderedArgs