From f7984224c1c422d8e61e80abea1ea252752bdace Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Mon, 1 Feb 2016 20:20:16 +0100 Subject: forms: Move regexp from utils The username and username_exclude regexp are only used in the forms, so we move the definition there. --- accounts/forms.py | 7 ++++++- accounts/utils/__init__.py | 4 ---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/accounts/forms.py b/accounts/forms.py index 8653653..82b999e 100644 --- a/accounts/forms.py +++ b/accounts/forms.py @@ -1,11 +1,16 @@ # -*- coding: utf-8 -*- +import re from flask import g, current_app, session, Markup from flask.ext.wtf import Form from flask.ext.login import current_user from wtforms import TextField, PasswordField, ValidationError, BooleanField,\ validators from wtforms.form import FormMeta -from utils import _username_re, _username_exclude_re, NotRegexp, url_for +from utils import NotRegexp, url_for + + +_username_re = re.compile(r'^[a-zA-Z][a-zA-Z0-9-]{1,15}$') +_username_exclude_re = re.compile(r'^(admin|root)') class RegisterForm(Form): diff --git a/accounts/utils/__init__.py b/accounts/utils/__init__.py index 06cf969..e584e28 100644 --- a/accounts/utils/__init__.py +++ b/accounts/utils/__init__.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- import importlib -import re from functools import wraps from flask import current_app, flash, g, redirect, render_template, request, session from flask import url_for as flask_url_for @@ -11,9 +10,6 @@ from wtforms.validators import Regexp, ValidationError from .confirmation import Confirmation -_username_re = re.compile(r'^[a-zA-Z][a-zA-Z0-9-]{1,15}$') -_username_exclude_re = re.compile(r'^(admin|root)') - # using http://flask.pocoo.org/docs/patterns/viewdecorators/ def templated(template=None): def templated_(f): -- cgit v1.2.3-1-g7c22