我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用werkzeug.http.parse_date()。
def loads(self, value): def object_hook(obj): if len(obj) != 1: return obj the_key, the_value = next(iteritems(obj)) if the_key == ' t': return tuple(the_value) elif the_key == ' u': return uuid.UUID(the_value) elif the_key == ' b': return b64decode(the_value) elif the_key == ' m': return Markup(the_value) elif the_key == ' d': return parse_date(the_value) return obj return json.loads(value, object_hook=object_hook)
def test_environ_property(self): class A(object): environ = {'string': 'abc', 'number': '42'} string = utils.environ_property('string') missing = utils.environ_property('missing', 'spam') read_only = utils.environ_property('number') number = utils.environ_property('number', load_func=int) broken_number = utils.environ_property('broken_number', load_func=int) date = utils.environ_property('date', None, parse_date, http_date, read_only=False) foo = utils.environ_property('foo') a = A() self.assert_equal(a.string, 'abc') self.assert_equal(a.missing, 'spam') def test_assign(): a.read_only = 'something' self.assert_raises(AttributeError, test_assign) self.assert_equal(a.number, 42) self.assert_equal(a.broken_number, None) self.assert_is_none(a.date) a.date = datetime(2008, 1, 22, 10, 0, 0, 0) self.assert_equal(a.environ['date'], 'Tue, 22 Jan 2008 10:00:00 GMT')