Merge ~cjwatson/launchpad:remove-dbschemaapi into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: c8e8e899a0eb44747624d1adca6b5be4b978fb12
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:remove-dbschemaapi
Merge into: launchpad:master
Diff against target: 128 lines (+1/-70)
4 files modified
lib/lp/app/browser/configure.zcml (+0/-7)
lib/lp/app/browser/tales.py (+0/-18)
lib/lp/app/doc/tales.rst (+1/-15)
lib/lp/app/tests/test_tales.py (+0/-30)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+412125@code.launchpad.net

Commit message

Remove deprecated DBSchemaAPI TALES adapter

Description of the change

This was deprecated long ago and is no longer used (difficult to search for, but confirmed by a full test run).

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) wrote :

This is a relatively straightforward code cleanup and doesn't need much review. I'm landing this so that I have a commit to use to let me deploy an unrelated config change easily.

The CI failure will be fixed by https://code.launchpad.net/~cjwatson/launchpad-buildd/+git/launchpad-buildd/+merge/436371.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/app/browser/configure.zcml b/lib/lp/app/browser/configure.zcml
2index cc40021..8d8ff75 100644
3--- a/lib/lp/app/browser/configure.zcml
4+++ b/lib/lp/app/browser/configure.zcml
5@@ -648,13 +648,6 @@
6 />
7
8 <adapter
9- for="int"
10- provides="zope.traversing.interfaces.IPathAdapter"
11- factory="lp.app.browser.tales.DBSchemaAPI"
12- name="lp"
13- />
14-
15- <adapter
16 for="datetime.datetime"
17 provides="zope.traversing.interfaces.IPathAdapter"
18 factory="lp.app.browser.tales.DateTimeFormatterAPI"
19diff --git a/lib/lp/app/browser/tales.py b/lib/lp/app/browser/tales.py
20index 89a29bc..ed832e8 100644
21--- a/lib/lp/app/browser/tales.py
22+++ b/lib/lp/app/browser/tales.py
23@@ -13,7 +13,6 @@ from textwrap import dedent
24 from urllib.parse import quote
25
26 import pytz
27-from lazr.enum import enumerated_type_registry
28 from lazr.restful.utils import get_current_browser_request
29 from lazr.uri import URI
30 from zope.browserpage import ViewPageTemplateFile
31@@ -448,23 +447,6 @@ class RequestAPI:
32 return params
33
34
35-@implementer(ITraversable)
36-class DBSchemaAPI:
37- """Adapter from integers to things that can extract information from
38- DBSchemas.
39- """
40-
41- def __init__(self, number):
42- self._number = number
43-
44- def traverse(self, name, furtherPath):
45- if name in enumerated_type_registry:
46- enum = enumerated_type_registry[name]
47- return enum.items[self._number].title
48- else:
49- raise TraversalError(name)
50-
51-
52 # Python 3 doesn't have types.NoneType, but we still need to be able to
53 # refer to the type of None from ZCML so that we can register the
54 # NoneFormatter adapter.
55diff --git a/lib/lp/app/doc/tales.rst b/lib/lp/app/doc/tales.rst
56index eb27ee5..162b579 100644
57--- a/lib/lp/app/doc/tales.rst
58+++ b/lib/lp/app/doc/tales.rst
59@@ -1569,21 +1569,6 @@ with 'None/fmt:foo'.
60 ''
61
62
63-The lp: namespace for presenting DBSchema items
64------------------------------------------------
65-
66-This is deprecated, and should raise a deprecation warning in the
67-future, and eventually be removed. It is no longer needed, now that we
68-have an EnumCol for sqlobject.
69-
70-Test the 'lp:' namespace for presenting DBSchema items.
71-
72- >>> from lp.soyuz.enums import BinaryPackageFormat
73- >>> deb = BinaryPackageFormat.DEB.value
74- >>> test_tales("deb/lp:BinaryPackageFormat", deb=deb)
75- 'Ubuntu Package'
76-
77-
78 The someobject/required:some.Permission helper
79 ----------------------------------------------
80
81@@ -1615,6 +1600,7 @@ template matches a particular valid value for that DBSchema enum.
82 This was going to be called 'enum-value', but Zope doesn't allow this.
83 To be fixed upstream.
84
85+ >>> from lp.soyuz.enums import BinaryPackageFormat
86 >>> deb = BinaryPackageFormat.DEB
87 >>> udeb = BinaryPackageFormat.UDEB
88 >>> test_tales("deb/enumvalue:DEB", deb=deb)
89diff --git a/lib/lp/app/tests/test_tales.py b/lib/lp/app/tests/test_tales.py
90index 2520a12..0230f4f 100644
91--- a/lib/lp/app/tests/test_tales.py
92+++ b/lib/lp/app/tests/test_tales.py
93@@ -100,36 +100,6 @@ def test_cookie_scope():
94 """
95
96
97-def test_dbschemaapi():
98- """
99- >>> from lp.app.browser.tales import DBSchemaAPI
100- >>> from lp.code.enums import BranchType
101-
102- The syntax to get the title is: number/lp:DBSchemaClass
103-
104- >>> (
105- ... str(DBSchemaAPI(1).traverse("BranchType", []))
106- ... == BranchType.HOSTED.title
107- ... )
108- True
109-
110- Using an inappropriate number should give a KeyError.
111-
112- >>> DBSchemaAPI(99).traverse("BranchType", [])
113- Traceback (most recent call last):
114- ...
115- KeyError: 99
116-
117- Using a dbschema name that doesn't exist should give a LocationError
118-
119- >>> DBSchemaAPI(99).traverse("NotADBSchema", [])
120- Traceback (most recent call last):
121- ...
122- LocationError: 'NotADBSchema'
123-
124- """
125-
126-
127 class TestPersonFormatterAPI(TestCaseWithFactory):
128 """Tests for PersonFormatterAPI"""
129

Subscribers

People subscribed via source and target branches

to status/vote changes: