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
diff --git a/lib/lp/app/browser/configure.zcml b/lib/lp/app/browser/configure.zcml
index cc40021..8d8ff75 100644
--- a/lib/lp/app/browser/configure.zcml
+++ b/lib/lp/app/browser/configure.zcml
@@ -648,13 +648,6 @@
648 />648 />
649649
650 <adapter650 <adapter
651 for="int"
652 provides="zope.traversing.interfaces.IPathAdapter"
653 factory="lp.app.browser.tales.DBSchemaAPI"
654 name="lp"
655 />
656
657 <adapter
658 for="datetime.datetime"651 for="datetime.datetime"
659 provides="zope.traversing.interfaces.IPathAdapter"652 provides="zope.traversing.interfaces.IPathAdapter"
660 factory="lp.app.browser.tales.DateTimeFormatterAPI"653 factory="lp.app.browser.tales.DateTimeFormatterAPI"
diff --git a/lib/lp/app/browser/tales.py b/lib/lp/app/browser/tales.py
index 89a29bc..ed832e8 100644
--- a/lib/lp/app/browser/tales.py
+++ b/lib/lp/app/browser/tales.py
@@ -13,7 +13,6 @@ from textwrap import dedent
13from urllib.parse import quote13from urllib.parse import quote
1414
15import pytz15import pytz
16from lazr.enum import enumerated_type_registry
17from lazr.restful.utils import get_current_browser_request16from lazr.restful.utils import get_current_browser_request
18from lazr.uri import URI17from lazr.uri import URI
19from zope.browserpage import ViewPageTemplateFile18from zope.browserpage import ViewPageTemplateFile
@@ -448,23 +447,6 @@ class RequestAPI:
448 return params447 return params
449448
450449
451@implementer(ITraversable)
452class DBSchemaAPI:
453 """Adapter from integers to things that can extract information from
454 DBSchemas.
455 """
456
457 def __init__(self, number):
458 self._number = number
459
460 def traverse(self, name, furtherPath):
461 if name in enumerated_type_registry:
462 enum = enumerated_type_registry[name]
463 return enum.items[self._number].title
464 else:
465 raise TraversalError(name)
466
467
468# Python 3 doesn't have types.NoneType, but we still need to be able to450# Python 3 doesn't have types.NoneType, but we still need to be able to
469# refer to the type of None from ZCML so that we can register the451# refer to the type of None from ZCML so that we can register the
470# NoneFormatter adapter.452# NoneFormatter adapter.
diff --git a/lib/lp/app/doc/tales.rst b/lib/lp/app/doc/tales.rst
index eb27ee5..162b579 100644
--- a/lib/lp/app/doc/tales.rst
+++ b/lib/lp/app/doc/tales.rst
@@ -1569,21 +1569,6 @@ with 'None/fmt:foo'.
1569 ''1569 ''
15701570
15711571
1572The lp: namespace for presenting DBSchema items
1573-----------------------------------------------
1574
1575This is deprecated, and should raise a deprecation warning in the
1576future, and eventually be removed. It is no longer needed, now that we
1577have an EnumCol for sqlobject.
1578
1579Test the 'lp:' namespace for presenting DBSchema items.
1580
1581 >>> from lp.soyuz.enums import BinaryPackageFormat
1582 >>> deb = BinaryPackageFormat.DEB.value
1583 >>> test_tales("deb/lp:BinaryPackageFormat", deb=deb)
1584 'Ubuntu Package'
1585
1586
1587The someobject/required:some.Permission helper1572The someobject/required:some.Permission helper
1588----------------------------------------------1573----------------------------------------------
15891574
@@ -1615,6 +1600,7 @@ template matches a particular valid value for that DBSchema enum.
1615This was going to be called 'enum-value', but Zope doesn't allow this.1600This was going to be called 'enum-value', but Zope doesn't allow this.
1616To be fixed upstream.1601To be fixed upstream.
16171602
1603 >>> from lp.soyuz.enums import BinaryPackageFormat
1618 >>> deb = BinaryPackageFormat.DEB1604 >>> deb = BinaryPackageFormat.DEB
1619 >>> udeb = BinaryPackageFormat.UDEB1605 >>> udeb = BinaryPackageFormat.UDEB
1620 >>> test_tales("deb/enumvalue:DEB", deb=deb)1606 >>> test_tales("deb/enumvalue:DEB", deb=deb)
diff --git a/lib/lp/app/tests/test_tales.py b/lib/lp/app/tests/test_tales.py
index 2520a12..0230f4f 100644
--- a/lib/lp/app/tests/test_tales.py
+++ b/lib/lp/app/tests/test_tales.py
@@ -100,36 +100,6 @@ def test_cookie_scope():
100 """100 """
101101
102102
103def test_dbschemaapi():
104 """
105 >>> from lp.app.browser.tales import DBSchemaAPI
106 >>> from lp.code.enums import BranchType
107
108 The syntax to get the title is: number/lp:DBSchemaClass
109
110 >>> (
111 ... str(DBSchemaAPI(1).traverse("BranchType", []))
112 ... == BranchType.HOSTED.title
113 ... )
114 True
115
116 Using an inappropriate number should give a KeyError.
117
118 >>> DBSchemaAPI(99).traverse("BranchType", [])
119 Traceback (most recent call last):
120 ...
121 KeyError: 99
122
123 Using a dbschema name that doesn't exist should give a LocationError
124
125 >>> DBSchemaAPI(99).traverse("NotADBSchema", [])
126 Traceback (most recent call last):
127 ...
128 LocationError: 'NotADBSchema'
129
130 """
131
132
133class TestPersonFormatterAPI(TestCaseWithFactory):103class TestPersonFormatterAPI(TestCaseWithFactory):
134 """Tests for PersonFormatterAPI"""104 """Tests for PersonFormatterAPI"""
135105

Subscribers

People subscribed via source and target branches

to status/vote changes: