summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2016-02-01 20:20:16 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2016-02-02 04:23:27 +0100
commitf7984224c1c422d8e61e80abea1ea252752bdace (patch)
tree5a6c45e1c3f35b461b2bdfb87935f6879495ff7c
parent7498b4dc956d6ea74f955027f867eab332a0fffa (diff)
downloadweb-f7984224c1c422d8e61e80abea1ea252752bdace.tar.gz
web-f7984224c1c422d8e61e80abea1ea252752bdace.tar.bz2
web-f7984224c1c422d8e61e80abea1ea252752bdace.zip
forms: Move regexp from utils
The username and username_exclude regexp are only used in the forms, so we move the definition there.
-rw-r--r--accounts/forms.py7
-rw-r--r--accounts/utils/__init__.py4
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):