Skip to content

Commit

Permalink
Merge branch '0.13-maintenance'
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism committed Oct 6, 2016
2 parents 6dbf1ce + 6bc79ae commit de697a0
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 16 deletions.
11 changes: 10 additions & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
Flask-WTF Changelog
===================

Full list of changes between each Flask-WTF release.
Version 0.13.1
--------------

Released 2016/10/6

- Deprecation warning for ``Form`` is shown during ``__init__`` instead of immediately when subclassing. (`#262`_)
- Don't use ``pkg_resources`` to get version, for compatibility with GAE. (`#261`_)

.. _`#261`: https://github.com/lepture/flask-wtf/issues/261
.. _`#262`: https://github.com/lepture/flask-wtf/issues/262

Version 0.13
------------
Expand Down
4 changes: 1 addition & 3 deletions flask_wtf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
# flake8: noqa
from __future__ import absolute_import

import pkg_resources

from .csrf import CsrfProtect
from .form import FlaskForm, Form
from .recaptcha import *

__version__ = pkg_resources.get_distribution('Flask-WTF').version
__version__ = '0.13.1'
18 changes: 8 additions & 10 deletions flask_wtf/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,15 @@ def _get_translations(self):
return translations


class DeprecatedFormMeta(FormMeta):
def __init__(cls, name, bases, attrs):
warnings.warn(FlaskWTFDeprecationWarning(
'"flask_wtf.Form" has been renamed to "FlaskForm" '
'and will be removed in 1.0.'
), stacklevel=2)
type.__init__(cls, name, bases, attrs)


class Form(with_metaclass(DeprecatedFormMeta, FlaskForm)):
class Form(FlaskForm):
"""
.. deprecated:: 0.13
Renamed to :class:`~flask_wtf.FlaskForm`.
"""

def __init__(self, *args, **kwargs):
warnings.warn(FlaskWTFDeprecationWarning(
'"flask_wtf.Form" has been renamed to "FlaskForm" '
'and will be removed in 1.0.'
), stacklevel=3)
super(Form, self).__init__(*args, **kwargs)
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/usr/bin/env python
from setuptools import setup, find_packages

with open('README.rst') as f:
readme = f.read()

setup(
name='Flask-WTF',
version='0.14',
Expand All @@ -11,7 +14,8 @@
maintainer='Hsiaoming Yang',
maintainer_email='[email protected]',
description='Simple integration of Flask and WTForms.',
packages=find_packages(),
long_description=readme,
packages=find_packages(exclude=('tests',)),
test_suite='nose.collector',
zip_safe=False,
platforms='any',
Expand Down
16 changes: 15 additions & 1 deletion tests/test_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,27 @@
from unittest import TestCase
from flask_wtf import Form
from flask_wtf._compat import FlaskWTFDeprecationWarning
from wtforms.compat import with_metaclass
from wtforms.form import FormMeta


class TestForm(TestCase):
def test_deprecated_form(self):
with warnings.catch_warnings():
warnings.simplefilter('error', FlaskWTFDeprecationWarning)
self.assertRaises(FlaskWTFDeprecationWarning, type, 'F', (Form,), {})

class F1(Form):
pass

self.assertRaises(FlaskWTFDeprecationWarning, F1)

class FMeta(FormMeta):
pass

class F2(with_metaclass(FMeta, Form)):
pass

self.assertRaises(FlaskWTFDeprecationWarning, F2)

def test_deprecated_html5(self):
with warnings.catch_warnings():
Expand Down

0 comments on commit de697a0

Please sign in to comment.