Suppress warnings from Werkzeug

- Werkzeug deprecated Request.is_xhr, but it works fine with jQuery and we
  don't need a reminder every time a unit test is run. When we upgrade to
  Werkzeug 1.0 (once that's released) we'll see things break and fix them.
- Werkzeug deprecated their Atom feed. This we should act on; tracked in
  https://developer.blender.org/T65274.
This commit is contained in:
Sybren A. Stüvel 2019-05-29 15:22:45 +02:00
parent 4425771117
commit 1f5f781ecf
2 changed files with 22 additions and 11 deletions

View File

@ -14,23 +14,28 @@ import os.path
import pathlib import pathlib
import warnings import warnings
import jinja2
import flask
from flask import g, render_template, request
from flask_babel import Babel, gettext as _
from flask.templating import TemplateNotFound
import pymongo.database
# These warnings have to be suppressed before the first import. # These warnings have to be suppressed before the first import.
# Eve is falling behind on Cerberus. See https://github.com/pyeve/eve/issues/1278 # Eve is falling behind on Cerberus. See https://github.com/pyeve/eve/issues/1278
warnings.filterwarnings( warnings.filterwarnings(
'ignore', category=DeprecationWarning, 'ignore', category=DeprecationWarning,
message="Methods for type testing are deprecated, use TypeDefinition and the " message="Methods for type testing are deprecated, use TypeDefinition and the "
"'types_mapping'-property of a Validator-instance instead") "'types_mapping'-property of a Validator-instance instead")
from werkzeug.local import LocalProxy # Werkzeug deprecated Request.is_xhr, but it works fine with jQuery and we don't need a reminder
# every time a unit test is run.
warnings.filterwarnings('ignore', category=DeprecationWarning,
message="'Request.is_xhr' is deprecated as of version 0.13 and will be "
"removed in version 1.0.")
import jinja2
import flask
from eve import Eve from eve import Eve
from flask import g, render_template, request
from flask_babel import Babel, gettext as _
from flask.templating import TemplateNotFound
import pymongo.database
from werkzeug.local import LocalProxy
# Declare pillar.current_app before importing other Pillar modules. # Declare pillar.current_app before importing other Pillar modules.
@ -913,7 +918,8 @@ class PillarServer(BlinkerCompatibleEve):
yield ctx yield ctx
def validator_for_resource(self, resource_name: str) -> custom_field_validation.ValidateCustomFields: def validator_for_resource(self,
resource_name: str) -> custom_field_validation.ValidateCustomFields:
schema = self.config['DOMAIN'][resource_name]['schema'] schema = self.config['DOMAIN'][resource_name]['schema']
validator = self.validator(schema, resource_name) validator = self.validator(schema, resource_name)
return validator return validator

View File

@ -1,5 +1,6 @@
import logging import logging
import urllib.parse import urllib.parse
import warnings
from pillarsdk import Node from pillarsdk import Node
from flask import Blueprint from flask import Blueprint
@ -7,7 +8,6 @@ from flask import current_app
from flask import render_template from flask import render_template
from flask import redirect from flask import redirect
from flask import request from flask import request
from werkzeug.contrib.atom import AtomFeed
from pillar.flask_extra import ensure_schema from pillar.flask_extra import ensure_schema
from pillar.web.utils import system_util from pillar.web.utils import system_util
@ -91,6 +91,11 @@ def error_403():
@blueprint.route('/feeds/blogs.atom') @blueprint.route('/feeds/blogs.atom')
def feeds_blogs(): def feeds_blogs():
"""Global feed generator for latest blogposts across all projects""" """Global feed generator for latest blogposts across all projects"""
# Werkzeug deprecated their Atom feed. Tracked in https://developer.blender.org/T65274.
with warnings.catch_warnings():
from werkzeug.contrib.atom import AtomFeed
@current_app.cache.cached(60*5) @current_app.cache.cached(60*5)
def render_page(): def render_page():
feed = AtomFeed('Blender Cloud - Latest updates', feed = AtomFeed('Blender Cloud - Latest updates',