class IntegrityError(DatabaseError):
"""Wraps a DB-API IntegrityError."""
class DatabaseError(DBAPIError):
"""Wraps a DB-API DatabaseError."""
try:
f = open('myfile.txt')
s = f.readline()
i = int(s.strip())
except IOError as e:
print "I/O error({0}): {1}".format(e.errno, e.strerror)
gulp.task('styles', function () {
return gulp.src('style.css')
.pipe(sourcemaps.init())
.pipe(minifyCss())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(output + '/css'))
});
WITH UsersRez AS
(
SELECT "user".role_id as role_id, "user".id as user_id, ROW_NUMBER()
OVER (ORDER BY timestamp DESC) AS RowNumber
FROM "user" where role_id={0}
)
SELECT RowNumber,user_id
FROM UsersRez
WHERE user_id = {1}
.format(current_user.role.id, current_user.id)class RegistrationForm(Form):
email = StringField(u'Электронная почта',
validators=[Required(REQ_TEXT),
Length(1, 64),
Email(REQ_TEXT)])
password = PasswordField(u'Пароль', validators=[
Required(REQ_TEXT)])
submit = SubmitField(u'Зарегистрироваться')
def validate_email(self, field):
if User.query.filter_by(email=field.data).first():
raise ValidationError(u'Почта уже занята')
REQ_TEXT = u'Заполните это поле'
class RegistrationForm(Form):
Nickname = TextField('Nickname', validators = [Required(REQ_TEXT)])
Password = TextField('Password', validators = [Required(u'Укажите пароль')])
email = StringField(u'Электронная почта',
validators=[Required(REQ_TEXT),
Length(1, 64),
Email(REQ_TEXT)])
def validate_email(self, field):
if User.query.filter_by(email=field.data).first():
raise ValidationError(u'Почта уже занята')
return redirect(url_for('.register_step2',
first_name=form.first_name.data,
age= form.gender.data,
gender=form.gender.data,
search_gender=form.search_gender.data
))
@mod.route('/welcome/1', methods=['GET', 'POST'])
def register_step1():
form = RegisterForm1()
if form.validate_on_submit():
'''
Что-то делаем
'''
return redirect(url_for('.register_step2', values=values))
'''
else:
return "No validate: {0}".format(dict(request.form))
Эта часть не нужна так-как form-errors на строне шаблонов можно отрабатывать
'''
return render_template('register1.html', form=form)
<form method="POST" action="{{url_for('mod.register_step1')}}" enctype="multipart/form-data">