Beispiel #1
0
def get_analytics_account():
    """Return the Google Analytics account id for the current application or
    `None` if there is no key or the key is invalid.
    """
    app = get_application()
    key = app.cfg['analytics/account']
    if key and check(is_valid_account_id, key, memorize=True):
        return key
Beispiel #2
0
def get_akismet_key():
    """Return the akismet key for the current application or
    `None` if there is no key or the key is invalid.
    """
    app = get_application()
    key = app.cfg['akismet_spam_filter/apikey']
    if key and check(is_valid_key, key, memorize=True):
        return key
Beispiel #3
0
def get_akismet_key():
    """Return the akismet key for the current application or
    `None` if there is no key or the key is invalid.
    """
    app = get_application()
    key = app.cfg['akismet_spam_filter/apikey']
    if key and check(is_valid_key, key, memorize=True):
        return key
Beispiel #4
0
def split_email(s):
    """Split a mail address:

    >>> split_email("John Doe")
    ('John Doe', None)
    >>> split_email("John Doe <*****@*****.**>")
    ('John Doe', '*****@*****.**')
    >>> split_email("*****@*****.**")
    (None, '*****@*****.**')
    """
    p1, p2 = _mail_split_re.search(s).groups()
    if p2:
        return p1, p2
    elif check(is_valid_email, p1):
        return None, p1
    return p1, None
Beispiel #5
0
 def test_admin_account(self, request):
     """Check if the admin mail is valid and the passwords match."""
     _ = request.translations.gettext
     errors = []
     if not request.values.get('admin_username'):
         errors.append(_('You have to provide a username.'))
     email = request.values.get('admin_email')
     if not email:
         errors.append(_('You have to enter a mail address.'))
     elif not check(is_valid_email, email):
         errors.append(_('The mail address is not valid.'))
     password = request.values.get('admin_password')
     if not password:
         errors.append(_('You have to enter a password.'))
     if password != request.values.get('admin_password2'):
         errors.append(_('The two passwords do not match.'))
     if errors:
         return {'error': errors[0]}