本文整理汇总了Python中web.form.regexp函数的典型用法代码示例。如果您正苦于以下问题:Python regexp函数的具体用法?Python regexp怎么用?Python regexp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了regexp函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: GET
def GET(self):
try:
posts=db.posts
query=posts.find({"user":web.cookies().user})
form_reg_editar = form.Form(
form.Textbox('nombre', form.notnull, form.regexp('^[A-Z, a-z]', 'No hay nadie en el mundo cuyo nombre tenga números.¡Use letras!'), description="Nombre", value=query[0]["nombre"]),
form.Textbox('apellidos', form.notnull, form.regexp('^[A-Z, a-z]', 'No hay nadie en el mundo cuyo apellido tenga números.¡Use letras!'), description="Apellido", value=query[0]["apellidos"]),
form.Textbox('correo', form.notnull, form.regexp('^[a-zA-Z0-9._%+-][email protected][a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$', 'Introduzca un correo válido'), description="Correo electrónico", value=query[0]["correo"]),
form.Dropdown('dias', dias, description="Dia", value=int(query[0]["dia"])),
form.Dropdown('meses', meses, description="Mes", value=int(query[0]["mes"])),
form.Dropdown('anios', anios, description="Anio", value=int(query[0]["anio"])),
form.Textarea('direccion', form.notnull, description="Dirección", value=query[0]["direccion"]),
form.Password('clave', form.notnull, description="Contraseña", value=query[0]["password"]),
form.Password('clave2', form.notnull, description="Repetir contraseña", value=query[0]["password"]),
form.Radio('pago', ['Contra reembolso', 'Tarjeta VISA'], description="Forma de pago", value=query[0]["pago"]),
form.Textbox('visa', form.regexp('((\d{4})[\-,\s](\d{4})[\-,\s](\d{4})[\-,\s](\d{4}))', 'Introduzca un número de tarjeta VISA válido'), description="Tarjeta VISA", value=query[0]["visa"]),
form.Button('Editar'),
validators = [form.Validator("Fecha de nacimiento no válida.", lambda i: (((int(i.meses) == 2) and ((int(i.dias) <= 28) and ((int(i.anios) % 4) != 0) or (int(i.dias) <= 29) and ((int(i.anios) % 4) == 0))) or ((int(i.dias) <= 31) and ((int(i.meses) == 1) or (int(i.meses) == 3) or (int(i.meses) == 5) or (int(i.meses) == 7) or (int(i.meses) == 8) or (int(i.meses) == 10) or (int(i.meses) == 12))) or ((int(i.dias) <= 30) and ((int(i.meses) == 4) or (int(i.meses) == 6) or (int(i.meses) == 9) or (int(i.meses) == 11))))), form.Validator("Las contraseñas no coinciden.", lambda i: i.clave == i.clave2), form.Validator('Míninmo 7 caracteres', lambda x:len(x.clave)>=7), form.Validator('Míninmo 7 caracteres', lambda x:len(x.clave2)>=7)]
)
res="Bienvenido usuario: %s " % (web.cookies().user)
web.setcookie('pagina3', web.cookies().pagina2)
web.setcookie('pagina2', web.cookies().pagina1)
web.setcookie('pagina1', "editar_perfil")
web.header('Content-Type', 'text/html; charset=utf-8')
return plantillas.editar_perfil(formulario=res, registro=form_reg_editar.render())
except:
l=form_log()
web.header('Content-Type', 'text/html; charset=utf-8')
return plantillas.pagina_desconectado(formulario=l.render(), mensaje="Se ha producido algun error. Inicie sesion de nuevo.")
开发者ID:JCristobal,项目名称:ProjectCC,代码行数:31,代码来源:script.py
示例2: settingsForm
def settingsForm(_guideUrl, _ip, _chButLeft, _chButTop, _chButSpc, _guideHeight, _useOnbrd):
return form.Form(
form.Textbox("guideUrl", form.notnull, size="50", description="Web guide address", value=_guideUrl),
form.Textbox("ip", form.notnull, description="MythTV frontend IP address", value=_ip),
form.Textbox("chButLeft",
form.notnull,
form.regexp('\d+', 'Must be a digit'),
form.Validator('Must be more than 0', lambda x:int(x)>0),
description="Channel buttons left margin",
value=_chButLeft),
form.Textbox("chButTop",
form.notnull,
form.regexp('\d+', 'Must be a digit'),
form.Validator('Must be more than 0', lambda x:int(x)>0),
description="Channel buttons top margin",
value=_chButTop),
form.Textbox("chButSpc",
form.notnull,
form.regexp('\d+', 'Must be a digit'),
form.Validator('Must be more than 0', lambda x:int(x)>0),
description="Channel buttons vertical spacing",
value=_chButSpc),
form.Textbox("guideHeight",
form.notnull,
form.regexp('\d+', 'Must be a digit'),
form.Validator('Must be more than 1000', lambda x:int(x)>1000),
description="Web guide height",
value=_guideHeight),
form.Checkbox('useonbrd', checked=_useOnbrd, value="cb1", description="Use Onboard keyboard"))
开发者ID:heyted,项目名称:mythbmote,代码行数:29,代码来源:mythbmote.py
示例3: check
def check(self):
from web import form
validList=(
form.Textbox("username", form.regexp(r".{3,20}$", 'User name: 3-20 chars')),
form.Password("password", form.regexp(r".{3,20}$", 'Password: 3-20 chars')),
)
if not self.validates(validList):
return self.error(self.errorMessage)
inputData = self.getInput()
if config.ADMIN_USERNAME == inputData['username'] and config.ADMIN_PASSWORD == inputData['password']:
self.setLogin(inputData['username'])
return self.success(msg='管理员登陆成功', url=self.makeUrl('/admin'))
else:
if not self.isInstalled():
return self.error(msg='用户登录失败, 系统未初始化!', url=self.makeUrl('/admin'))
userName = inputData['username']
password = hashlib.md5(inputData['password']).hexdigest()
try:
userObj = Users().select().where(Users.name == userName)
if userObj.where(Users.name == userName, Users.password == password).exists() == False:
return self.error(msg='用户登录失败,请检查用户名和密码是否匹配', url=self.makeUrl('/admin'))
self.setLogin(inputData['username'])
return self.success(msg='用户登陆成功', url=self.makeUrl('/admin'))
except Users.DoesNotExist:
return self.error(msg='用户登录失败,请检查用户名和密码是否匹配!', url=self.makeUrl('/admin'))
开发者ID:XinMa1,项目名称:work,代码行数:28,代码来源:referer.py
示例4: comment
def comment(self):
userInput= self.getInput()
cmsObj = model.cms()
cmsId = userInput['cmsId']
condition = {'status':1,'id':cmsId}
atl = cmsObj.getOne('*',condition)
if atl == None:
return self.error('文章不存在')
from web import form
validList=(
form.Textbox("name",form.regexp(r".{3,100}$", '姓名需为3~100个字符')),
form.Textbox("content",form.regexp(r".{1,100}$", '评论内容需为3~100个字符')),
form.Textbox("email", form.regexp(r".*@.*", '邮箱格式错误')),
form.Textbox("email",form.regexp(r".{5,100}$", '邮箱需为5~100个字符')),
)
if not self.validates(validList):
return self.error(self.errorMessage)
date = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())
HTTP_X_REAL_IP = web.ctx.env.get('HTTP_X_REAL_IP')
ip=HTTP_X_REAL_IP if HTTP_X_REAL_IP else web.ctx.ip
data={
'cmsId':cmsId,
'content':userInput['content'],
'name':userInput['name'],
'email':userInput['email'],
'createTime':date,
'ip':ip,
'status':1
}
model.comment().insert(data)
data = {'commentCount':atl['commentCount']+1}
model.cms().update(data,condition)
return self.success('评论成功',self.referer)
开发者ID:five3,项目名称:weblog,代码行数:33,代码来源:index.py
示例5: comment
def comment(self):
userInput= self.getInput()
cmsObj = model.cms()
cmsId = userInput['cmsId']
condition = {'status':1,'id':cmsId}
atl = cmsObj.getOne('*',condition)
if atl == None:
return self.error('not exist')
from web import form
validList=(
form.Textbox("name",form.regexp(r".{3,100}$", 'name length 3-100')),
form.Textbox("content",form.regexp(r".{1,200}$", 'comment length 1-200')),
form.Textbox("email", form.regexp(r".*@.*", 'error email format')),
form.Textbox("email",form.regexp(r".{5,100}$", 'email length 5-100')),
)
if not self.validates(validList):
return self.error(self.errorMessage)
date = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())
ip=web.ctx.ip
data={
'cmsId':cmsId,
'content':userInput['content'],
'name':userInput['name'],
'email':userInput['email'],
'createTime':date,
'ip':ip,
'status':1
}
commentid = model.comment().insert(data)
data = {'commentCount':atl['commentCount']+1}
model.cms().update(data,condition)
return self.success('comment success, comment id '+str(commentid)+'~',self.referer)
开发者ID:5alt,项目名称:0CTF2015Final0cms,代码行数:32,代码来源:index.py
示例6: getForm
def getForm(self):
return form.Form(
form.Textbox("home",
form.notnull,
description="Home location",
value=settings.get('location_home'),
),
form.Textbox("work",
form.notnull,
description="Work location",
value=settings.get('location_work'),
),
form.Textbox("weatherloc",
form.notnull,
description="Weather location",
value=settings.get('weather_location'),
),
form.Textbox("snooze",
form.notnull,
form.regexp('\d+', 'Must be a digit'),
description="Snooze Length (minutes)",
value=settings.getInt('snooze_length'),
),
form.Textbox("wakeup",
form.notnull,
form.regexp('\d+', 'Must be a digit'),
description="Time (mins) before event for alarm",
value=settings.getInt('wakeup_time'),
),
form.Textbox("precancel",
form.notnull,
form.regexp('\d+', 'Must be a digit'),
description="Pre-empt cancel alarm allowed (secs)",
value=settings.get('preempt_cancel'),
),
form.Textbox("waketime",
form.notnull,
form.regexp('[0-2][0-9][0-5][0-9]', 'Must be a 24hr time'),
description="Default wakeup time",
value=settings.get('default_wake'),
),
form.Checkbox("holidaymode",
description="Holiday mode enabled",
checked=(settings.getInt('holiday_mode')==1),
value="holiday",
),
form.Checkbox("weatheronalarm",
description="Play weather after alarm",
checked=(settings.getInt('weather_on_alarm')==1),
value="weatheronalarm",
),
form.Checkbox("sfx",
description="SFX enabled",
checked=(settings.getInt('sfx_enabled')==1),
value="sfx",
),
)
开发者ID:simcop2387,项目名称:alarmpi,代码行数:57,代码来源:Web.py
示例7: getForm
def getForm(self):
return form.Form(
form.Textbox("home", form.notnull, description="Home location", value=settings.get("location_home")),
form.Textbox("work", form.notnull, description="Work location", value=settings.get("location_work")),
form.Textbox(
"weatherloc", form.notnull, description="Weather location", value=settings.get("weather_location")
),
form.Textbox(
"snooze",
form.notnull,
form.regexp("\d+", "Must be a digit"),
description="Snooze Length (minutes)",
value=settings.getInt("snooze_length"),
),
form.Textbox(
"wakeup",
form.notnull,
form.regexp("\d+", "Must be a digit"),
description="Time (mins) before event for alarm",
value=settings.getInt("wakeup_time"),
),
form.Textbox(
"precancel",
form.notnull,
form.regexp("\d+", "Must be a digit"),
description="Pre-empt cancel alarm allowed (secs)",
value=settings.get("preempt_cancel"),
),
form.Textbox(
"waketime",
form.notnull,
form.regexp("[0-2][0-9][0-5][0-9]", "Must be a 24hr time"),
description="Default wakeup time",
value=settings.get("default_wake"),
),
form.Checkbox(
"holidaymode",
description="Holiday mode enabled",
checked=(settings.getInt("holiday_mode") == 1),
value="holiday",
),
form.Checkbox(
"weatheronalarm",
description="Play weather after alarm",
checked=(settings.getInt("weather_on_alarm") == 1),
value="weatheronalarm",
),
form.Checkbox("sfx", description="SFX enabled", checked=(settings.getInt("sfx_enabled") == 1), value="sfx"),
form.Textbox("ttspath", description="TTS path", value=settings.get("tts_path")),
)
开发者ID:mattdy,项目名称:alarmpi,代码行数:50,代码来源:Web.py
示例8: insertarDatosForm
def insertarDatosForm(data):
conDatos = form.Form(
form.Textbox('Nombre',
form.notnull,
class_='form-control',
value=str(data["nombre"])),
form.Textbox('Apellidos',
form.notnull,
class_='form-control',
value=str(data["apellidos"])),
form.Textbox('Email',
form.notnull,
form.regexp('[^@][email protected][^@]+\.[^@]+', 'Debe se ser un email'),
class_='form-control',
value=str(data["email"])),
form.Dropdown('Dia',
range(1, 31),
class_='form-control',
value=int(data["dia"])),
form.Dropdown('Mes',
range(1, 12),
class_='form-control',
value=int(data["mes"])),
form.Dropdown('Ano',
range(1900, 2014),
class_='form-control',
value=int(data["ano"])),
form.Textarea('Direccion',
form.notnull,
class_='form-control',
value=str(data["direccion"])),
form.Password('Contrasena',
form.regexp('[\d\w]{7,}',"Ha de tener al menos 7 caracteres"),
class_='form-control'),
form.Password('Contrasena2',
class_='form-control',
description="Repite contrasena: "),
form.Radio('Pago', ['Efectivo', 'VISA'],
class_='radio-inline',
checked=str(data["pago"])),
form.Textbox('Visa',
form.regexp('([0-9]{4}[\s-]){3}[0-9]{4}', 'La tarjeta ha de ser XXXX-XXXX-XXXX-XXXX con guiones o con espacios'),
class_='form-control',
description="Numero de tarjeta VISA: ",
value=str(data["visa"])),
validators=[form.Validator('Las contrasenas han de ser iguales.', lambda i: i.Contrasena == i['Repite contrasena'])])
return conDatos
开发者ID:ivanortegaalba,项目名称:DAI_2014-2015,代码行数:48,代码来源:persistencia-mongo-10.py
示例9: check
def check(self):
from web import form
validList=(
form.Textbox("username",form.regexp(r".{3,20}$", '用户名为3~20个字符')),
form.Password("password", form.regexp(r".{3,20}$", '密码为3~20个字符')),
)
if not self.validates(validList):
return self.error(self.errorMessage)
inputData = self.getInput()
settings = self.getSettings()
if settings.ADMIN_USERNAME == inputData['username'] and settings.ADMIN_PASSWORD == inputData['password']:
userData={'username':inputData['username']}
self.setLogin(userData)
return self.success('登陆成功',self.makeUrl('cms','list'))
else:
return self.error('账号或密码错误',self.makeUrl('admin',''))
开发者ID:jatter,项目名称:pywebtest,代码行数:16,代码来源:admin.py
示例10: num_box
def num_box(name, desc):
return form.Textbox(
name,
form.notnull,
form.regexp('^\s*\d+\s*$', "Digits only, please."),
size="10",
description=desc)
开发者ID:marklar,项目名称:massiu,代码行数:7,代码来源:ui_util.py
示例11: __init__
def __init__ ( self ):
Form.__init__ ( self,
Textbox('name', size=30, description="用户名", class_='sl', disabled='disabled'),
Textbox('email', EmailValidator, size=30, description="邮箱", class_='sl'),
Textbox('signature', regexp(r".{0,100}$", ' 请不要超过100个字符'), size=30, description="签名", class_='sl'),
Textbox('outsite_link', LinkValidator, size=30, description="主页", class_='sl'),
Button('保存设置', class_='super normal button')
)
开发者ID:nasawz,项目名称:post_bar,代码行数:8,代码来源:forms.py
示例12: check
def check(self):
from web import form
validList = (
form.Textbox("username", form.regexp(r".{3,20}$", "User name: 3-20 chars")),
form.Password("password", form.regexp(r".{3,20}$", "Password: 3-20 chars")),
)
if not self.validates(validList):
return self.error(self.errorMessage)
inputData = self.getInput()
if config.ADMIN_USERNAME == inputData["username"] and config.ADMIN_PASSWORD == inputData["password"]:
self.setLogin(inputData["username"])
return self.success(msg="管理员登陆成功", url=self.makeUrl("/admin"))
return self.error(msg="用户登录失败,请检查用户名和密码是否匹配!", url=self.makeUrl("/admin"))
开发者ID:XinMa1,项目名称:work,代码行数:17,代码来源:referer.py
示例13: buildForm
def buildForm():
return form.Form(
form.Textbox("userDispName", form.notnull, description="Display name"),
form.Textbox("glId", form.notnull, description="SPOT key"),
form.Textbox("userEmail", form.regexp(r".*@.*", "Must be a valid email address"), description="Email address"),
form.Textbox("userWebsite", description="Website"),
form.File("userImage", description="Optional custom user image"),
# form.Textbox("userIM", description="IM nickname")
)
开发者ID:thenewwazoo,项目名称:WhereAmIRiding,代码行数:9,代码来源:datamodels.py
示例14: make_profile_form
def make_profile_form(self):
f = form.Form(form.Textbox('email',
form.notnull,
form.regexp('^[\w-]+(\.[\w-]+)*@([a-z0-9-]+(\.[a-z0-9-]+)*?\.[a-z]{2,6}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?$', 'Invalid email address'),
value=self.user.email),
form.Textbox('homepage', value=self.user.homepage),
form.Textarea('description',
value=self.user.description),
form.Button('Save'))
return f
开发者ID:Etenil,项目名称:anvil,代码行数:10,代码来源:user.py
示例15: make_edit_form
def make_edit_form(self, proj):
edit_form = form.Form(
form.Textbox(
"name",
form.notnull,
form.regexp("^[a-z0-9._-]+$", "Name must only include low-case letters, digits, '.'. '_' and '-'"),
value=proj.name,
),
form.Textbox("homepage", value=proj.homepage),
form.Textarea("description", value=proj.description),
form.Button("Save"),
)
return edit_form
开发者ID:Etenil,项目名称:anvil,代码行数:13,代码来源:project.py
示例16: getAlarmForm
def getAlarmForm(self):
global alarm
nextAlarm = alarm.getNextAlarm()
alarmTime = ""
if nextAlarm is not None:
alarmTime = nextAlarm.strftime("%I%M")
return form.Form(
form.Textbox("time",
form.notnull,
form.regexp('[0-2][0-9][0-5][0-9]', 'Must be a 24hr time'),
description="Set alarm time",
value = alarmTime,
),
)
开发者ID:knnniggett,项目名称:alarmpi,代码行数:17,代码来源:Web.py
示例17: Login
def Login():
"""
Generates Login Form
"""
vusername = form.regexp(r".{3,50}$", 'must be between 3 and 20 characters')
#validator of the username
login = form.Form(
form.Textbox(
'username',vusername,
description="USERNAME"
),
form.Password(
'password',
description="PASSWORD"
),
validators = [
form.Validator(
"Username and Password can't be the same",
lambda i: i.username != i.password
)
]
)
return login
开发者ID:knarfytrebil,项目名称:MF-MANA,代码行数:24,代码来源:forms.py
示例18: render_mako
# Templates de mako
render = render_mako(
directories = ['templates'],
input_encoding = 'utf-8',
output_encoding = 'utf-8')
# Formulario de acceso
form_acceso = form.Form(
form.Textbox("usuario", form.notnull, description="Usuario:"),
form.Password("password", form.notnull, description="Contraseña:"),
form.Button("Acceder", type="submit"),
)
# Expresiones regulares validación
vTexto = form.regexp(r"^[\w\s]+$", '* Campo vacío.')
vEmail = form.regexp(r"^[a-zA-Z0-9._%+-][email protected][a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$", '* Correo electrónico no válido.')
vVISA = form.regexp(r"^([0-9]{4}) ([0-9]{4}) ([0-9]{4}) ([0-9]{4})$|^([0-9]{4})-([0-9]{4})-([0-9]{4})-([0-9]{4})$", '* Número tarjeta VISA no válido.')
vpass = form.regexp(r"\w{8,}$", '* Mínimo 8 caracteres.')
# Formulario de registro
form_datos = form.Form(
form.Textbox("usuario", vTexto, description = "Usuario:"),
form.Password("password", vpass, description = "Contraseña:"),
form.Password("verificacion", vpass, description = "Verificar contraseña:"),
form.Textbox("nombre", vTexto, description = "Nombre:"),
form.Textbox("apellidos", vTexto, description = "Apellidos:"),
form.Textbox("correo", vEmail, description = "Correo electrónico:"),
form.Textbox("visa", vVISA, description = "Número de VISA:"),
form.Dropdown("dia", range(1, 32), description = "Día:"),
form.Dropdown("mes", range(1, 13), description = "Mes:"),
开发者ID:AndreaPaz,项目名称:trabajos_universidad,代码行数:30,代码来源:practica_4.py
示例19: start_and_len
('bpl139.mrc', 50000),
('bpl140.mrc', 50000),
('bpl141.mrc', 50000),
('bpl142.mrc', 50000),
('bpl143.mrc', 50000),
('bpl144.mrc', 50000),
('bpl145.mrc', 50000),
('bpl146.mrc', 50000),
('bpl147.mrc', 41036),
)
myform = form.Form(
form.Dropdown('file', [(i, "%s - %d records" % (i, j)) for i, j in files]),
form.Textbox("start",
form.notnull,
form.regexp('\d+', 'Must be a digit'),
form.Validator('Must be less than 50000', lambda x:int(x)>50000)),
form.Textbox("count",
form.notnull,
form.regexp('\d+', 'Must be a digit'),
form.Validator('Must be less than 50000', lambda x:int(x)>50000)))
def start_and_len(file, start, count):
f = urllib2.urlopen("http://archive.org/download/bpl_marc/" + file)
pos = 0
num = 0
start_pos = None
while num < start + count:
data = f.read(5)
if data == '':
break
开发者ID:RaceList,项目名称:openlibrary,代码行数:31,代码来源:download.py
示例20: Logout
session.loggedin = True
session.username = username
raise web.seeother("/")
else:
return homepage_render.login("Login Failed", session.loggedin)
class Logout(object):
def GET(self):
session.loggedin = False
session.kill()
raise web.seeother("/")
# email validator
vemail = form.regexp(r".*@.*", "must be a valid email address")
# New user form
new_user_form = form.Form(
form.Textbox("username", description="Username"),
form.Textbox("email", vemail, description="E-Mail"),
form.Password("password", description="Password"),
form.Password("password_again", description="Confirm Password"),
validators=[form.Validator("Passwords didn't match.", lambda i: i.password == i.password_again)],
)
# Create a new user page
class NewUser(object):
def GET(self):
cur_form = new_user_form()
return homepage_render.newuser("New User", cur_form, session.loggedin)
开发者ID:christophski,项目名称:moodboard,代码行数:31,代码来源:auto.py
注:本文中的web.form.regexp函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论