Merge lp:~abentley/launchpad/no-proxy-warnings into lp:launchpad

Proposed by Aaron Bentley
Status: Merged
Merged at revision: 11303
Proposed branch: lp:~abentley/launchpad/no-proxy-warnings
Merge into: lp:launchpad
Diff against target: 28 lines (+4/-2)
1 file modified
lib/lp/testing/factory.py (+4/-2)
To merge this branch: bzr merge lp:~abentley/launchpad/no-proxy-warnings
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Review via email: mp+31781@code.launchpad.net

Commit message

Disable proxy warnings except when explicitly enabled.

Description of the change

= Summary =
Disable proxy warnings except when explicitly enabled.

== Proposed fix ==
When the environment variable 'PROXY_WARNINGS' is set to '1', emit warnings.
When it is unset or set to other values, emit no warnings.

== Pre-implementation notes ==
Discussed disabling on list. Julian Edwards and Robert Collins were positive
about it.

== Implementation details ==
None

== Tests ==
bin/test test_linkedbranch
PROXY_WARNINGS=1 bin/test test_linkedbranch

== Demo and Q/A ==
None

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/testing/factory.py

./lib/lp/testing/factory.py
      32: redefinition of unused 'os' from line 31

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

Lets call the variable ZOPE_PROXY_WARNINGS or something like that.

-Rob

Revision history for this message
Tim Penhey (thumper) :
review: Approve
Revision history for this message
Tim Penhey (thumper) wrote :

We have an env variable called LP_DEBUG_EXTRA and LP_DEBUG, so lets call this LP_PROXY_WARNINGS.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/testing/factory.py'
2--- lib/lp/testing/factory.py 2010-08-04 00:47:20 +0000
3+++ lib/lp/testing/factory.py 2010-08-05 20:03:49 +0000
4@@ -28,6 +28,7 @@
5 from email.mime.multipart import MIMEMultipart
6 from itertools import count
7 from operator import isSequenceType
8+import os
9 import os.path
10 from random import randint
11 from StringIO import StringIO
12@@ -2866,7 +2867,7 @@
13
14 def __getattr__(self, name):
15 attr = getattr(self._factory, name)
16- if callable(attr):
17+ if os.environ.get('LP_PROXY_WARNINGS') == '1' and callable(attr):
18
19 def guarded_method(*args, **kw):
20 result = attr(*args, **kw)
21@@ -2889,5 +2890,6 @@
22 This function should only be used in legacy tests which fail because
23 they expect unproxied objects.
24 """
25- warnings.warn(ShouldThisBeUsingRemoveSecurityProxy(obj), stacklevel=2)
26+ if os.environ.get('LP_PROXY_WARNINGS') == '1':
27+ warnings.warn(ShouldThisBeUsingRemoveSecurityProxy(obj), stacklevel=2)
28 return removeSecurityProxy(obj)