Merge lp:~cjwatson/launchpad/custom-widget-no-class-advice-5 into lp:launchpad

Proposed by Colin Watson on 2018-09-13
Status: Merged
Merged at revision: 18778
Proposed branch: lp:~cjwatson/launchpad/custom-widget-no-class-advice-5
Merge into: lp:launchpad
Diff against target: 684 lines (+95/-120)
14 files modified
lib/lp/app/browser/launchpadform.py (+0/-26)
lib/lp/services/features/browser/edit.py (+3/-3)
lib/lp/services/verification/browser/logintoken.py (+8/-7)
lib/lp/services/webhooks/browser.py (+3/-4)
lib/lp/snappy/browser/snap.py (+17/-16)
lib/lp/soyuz/browser/archive.py (+21/-19)
lib/lp/soyuz/browser/archivesubscription.py (+8/-8)
lib/lp/soyuz/browser/livefs.py (+3/-4)
lib/lp/translations/browser/hastranslationimports.py (+12/-9)
lib/lp/translations/browser/language.py (+6/-5)
lib/lp/translations/browser/person.py (+5/-5)
lib/lp/translations/browser/potemplate.py (+5/-6)
lib/lp/translations/browser/productseries.py (+2/-4)
lib/lp/translations/browser/translationimportqueue.py (+2/-4)
To merge this branch: bzr merge lp:~cjwatson/launchpad/custom-widget-no-class-advice-5
Reviewer Review Type Date Requested Status
William Grant code 2018-09-13 Approve on 2018-09-13
Review via email: mp+354843@code.launchpad.net

Commit message

Finish removing Zope class advice from custom widget registration.

To post a comment you must log in.
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/app/browser/launchpadform.py'
2--- lib/lp/app/browser/launchpadform.py 2018-08-09 14:31:23 +0000
3+++ lib/lp/app/browser/launchpadform.py 2018-09-13 08:25:30 +0000
4@@ -8,7 +8,6 @@
5
6 __all__ = [
7 'action',
8- 'custom_widget',
9 'has_structured_doc',
10 'LaunchpadEditFormView',
11 'LaunchpadFormView',
12@@ -41,7 +40,6 @@
13 implementer,
14 providedBy,
15 )
16-from zope.interface.advice import addClassAdvisor
17 from zope.traversing.interfaces import (
18 ITraversable,
19 TraversalError,
20@@ -80,8 +78,6 @@
21 schema = None
22 # Subset of fields to use
23 field_names = None
24- # Dictionary mapping field names to custom widgets
25- custom_widgets = {}
26
27 # The next URL to redirect to on successful form submission
28 next_url = None
29@@ -205,8 +201,6 @@
30 if field.custom_widget is None:
31 widget = getattr(
32 self, 'custom_widget_%s' % field.__name__, None)
33- if widget is None:
34- widget = self.custom_widgets.get(field.__name__)
35 if widget is not None:
36 if IWidgetFactory.providedBy(widget):
37 field.custom_widget = widget
38@@ -488,26 +482,6 @@
39 return was_changed
40
41
42-class custom_widget:
43- """A class advisor for overriding the default widget for a field."""
44-
45- def __init__(self, field_name, widget, *args, **kwargs):
46- self.field_name = field_name
47- if widget is None:
48- self.widget = None
49- else:
50- self.widget = CustomWidgetFactory(widget, *args, **kwargs)
51- addClassAdvisor(self.advise)
52-
53- def advise(self, cls):
54- if cls.custom_widgets is None:
55- cls.custom_widgets = {}
56- else:
57- cls.custom_widgets = dict(cls.custom_widgets)
58- cls.custom_widgets[self.field_name] = self.widget
59- return cls
60-
61-
62 def safe_action(action):
63 """A decorator used to mark a particular action as 'safe'.
64
65
66=== modified file 'lib/lp/services/features/browser/edit.py'
67--- lib/lp/services/features/browser/edit.py 2013-04-10 08:09:05 +0000
68+++ lib/lp/services/features/browser/edit.py 2018-09-13 08:25:30 +0000
69@@ -1,4 +1,4 @@
70-# Copyright 2010 Canonical Ltd. This software is licensed under the
71+# Copyright 2010-2018 Canonical Ltd. This software is licensed under the
72 # GNU Affero General Public License version 3 (see the file LICENSE).
73
74 """View and edit feature rules."""
75@@ -13,13 +13,13 @@
76 from difflib import unified_diff
77 import logging
78
79+from zope.formlib.widget import CustomWidgetFactory
80 from zope.formlib.widgets import TextAreaWidget
81 from zope.interface import Interface
82 from zope.schema import Text
83
84 from lp.app.browser.launchpadform import (
85 action,
86- custom_widget,
87 LaunchpadFormView,
88 )
89 from lp.app.browser.stringformatter import FormattersAPI
90@@ -59,7 +59,7 @@
91 page_title = label = 'Feature control'
92 diff = None
93 logger_name = 'lp.services.features'
94- custom_widget('comment', TextAreaWidget, height=2)
95+ custom_widget_comment = CustomWidgetFactory(TextAreaWidget, height=2)
96
97 @property
98 def field_names(self):
99
100=== modified file 'lib/lp/services/verification/browser/logintoken.py'
101--- lib/lp/services/verification/browser/logintoken.py 2018-03-02 16:17:35 +0000
102+++ lib/lp/services/verification/browser/logintoken.py 2018-09-13 08:25:30 +0000
103@@ -1,4 +1,4 @@
104-# Copyright 2009-2013 Canonical Ltd. This software is licensed under the
105+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
106 # GNU Affero General Public License version 3 (see the file LICENSE).
107
108 __metaclass__ = type
109@@ -18,6 +18,7 @@
110 import urllib
111
112 from zope.component import getUtility
113+from zope.formlib.widget import CustomWidgetFactory
114 from zope.formlib.widgets import TextAreaWidget
115 from zope.interface import (
116 alsoProvides,
117@@ -29,7 +30,6 @@
118 from lp import _
119 from lp.app.browser.launchpadform import (
120 action,
121- custom_widget,
122 LaunchpadEditFormView,
123 LaunchpadFormView,
124 )
125@@ -176,11 +176,12 @@
126 'teamowner', 'display_name', 'description', 'membership_policy',
127 'defaultmembershipperiod', 'renewal_policy', 'defaultrenewalperiod']
128 label = 'Claim Launchpad team'
129- custom_widget('description', TextAreaWidget, height=10, width=30)
130- custom_widget(
131- 'renewal_policy', LaunchpadRadioWidget, orientation='vertical')
132- custom_widget(
133- 'membership_policy', LaunchpadRadioWidget, orientation='vertical')
134+ custom_widget_description = CustomWidgetFactory(
135+ TextAreaWidget, height=10, width=30)
136+ custom_widget_renewal_policy = CustomWidgetFactory(
137+ LaunchpadRadioWidget, orientation='vertical')
138+ custom_widget_membership_policy = CustomWidgetFactory(
139+ LaunchpadRadioWidget, orientation='vertical')
140
141 expected_token_types = (LoginTokenType.TEAMCLAIM,)
142
143
144=== modified file 'lib/lp/services/webhooks/browser.py'
145--- lib/lp/services/webhooks/browser.py 2015-10-26 11:47:38 +0000
146+++ lib/lp/services/webhooks/browser.py 2018-09-13 08:25:30 +0000
147@@ -1,4 +1,4 @@
148-# Copyright 2015 Canonical Ltd. This software is licensed under the
149+# Copyright 2015-2018 Canonical Ltd. This software is licensed under the
150 # GNU Affero General Public License version 3 (see the file LICENSE).
151
152 """Webhook browser and API classes."""
153@@ -17,7 +17,6 @@
154
155 from lp.app.browser.launchpadform import (
156 action,
157- custom_widget,
158 LaunchpadEditFormView,
159 LaunchpadFormView,
160 )
161@@ -119,7 +118,7 @@
162 page_title = label = "Add webhook"
163
164 schema = WebhookEditSchema
165- custom_widget('event_types', LabeledMultiCheckBoxWidget)
166+ custom_widget_event_types = LabeledMultiCheckBoxWidget
167
168 @property
169 def inside_breadcrumb(self):
170@@ -152,7 +151,7 @@
171 schema = WebhookEditSchema
172 # XXX wgrant 2015-08-04: Need custom widget for secret.
173 field_names = ['delivery_url', 'event_types', 'active']
174- custom_widget('event_types', LabeledMultiCheckBoxWidget)
175+ custom_widget_event_types = LabeledMultiCheckBoxWidget
176
177 def initialize(self):
178 super(WebhookView, self).initialize()
179
180=== modified file 'lib/lp/snappy/browser/snap.py'
181--- lib/lp/snappy/browser/snap.py 2018-08-30 16:15:20 +0000
182+++ lib/lp/snappy/browser/snap.py 2018-09-13 08:25:30 +0000
183@@ -25,6 +25,7 @@
184 )
185 from zope.component import getUtility
186 from zope.error.interfaces import IErrorReportingUtility
187+from zope.formlib.widget import CustomWidgetFactory
188 from zope.interface import Interface
189 from zope.schema import (
190 Choice,
191@@ -35,7 +36,6 @@
192 from lp import _
193 from lp.app.browser.launchpadform import (
194 action,
195- custom_widget,
196 LaunchpadEditFormView,
197 LaunchpadFormView,
198 render_radio_widget_part,
199@@ -263,9 +263,9 @@
200 description=u'The package stream within the source distribution '
201 'series to use when building the snap package.')
202
203- custom_widget('archive', SnapArchiveWidget)
204- custom_widget('distro_arch_series', LabeledMultiCheckBoxWidget)
205- custom_widget('pocket', LaunchpadDropdownWidget)
206+ custom_widget_archive = SnapArchiveWidget
207+ custom_widget_distro_arch_series = LabeledMultiCheckBoxWidget
208+ custom_widget_pocket = LaunchpadDropdownWidget
209
210 help_links = {
211 "pocket": u"/+help-snappy/snap-build-pocket.html",
212@@ -400,11 +400,11 @@
213 'store_name',
214 'store_channels',
215 ]
216- custom_widget('store_distro_series', LaunchpadRadioWidget)
217- custom_widget('auto_build_archive', SnapArchiveWidget)
218- custom_widget('auto_build_pocket', LaunchpadDropdownWidget)
219- custom_widget('auto_build_channels', SnapBuildChannelsWidget)
220- custom_widget('store_channels', StoreChannelsWidget)
221+ custom_widget_store_distro_series = LaunchpadRadioWidget
222+ custom_widget_auto_build_archive = SnapArchiveWidget
223+ custom_widget_auto_build_pocket = LaunchpadDropdownWidget
224+ custom_widget_auto_build_channels = SnapBuildChannelsWidget
225+ custom_widget_store_channels = StoreChannelsWidget
226
227 help_links = {
228 "auto_build_pocket": u"/+help-snappy/snap-build-pocket.html",
229@@ -696,13 +696,14 @@
230 'store_name',
231 'store_channels',
232 ]
233- custom_widget('store_distro_series', LaunchpadRadioWidget)
234- custom_widget('vcs', LaunchpadRadioWidget)
235- custom_widget('git_ref', GitRefWidget, allow_external=True)
236- custom_widget('auto_build_archive', SnapArchiveWidget)
237- custom_widget('auto_build_pocket', LaunchpadDropdownWidget)
238- custom_widget('auto_build_channels', SnapBuildChannelsWidget)
239- custom_widget('store_channels', StoreChannelsWidget)
240+ custom_widget_store_distro_series = LaunchpadRadioWidget
241+ custom_widget_vcs = LaunchpadRadioWidget
242+ custom_widget_git_ref = CustomWidgetFactory(
243+ GitRefWidget, allow_external=True)
244+ custom_widget_auto_build_archive = SnapArchiveWidget
245+ custom_widget_auto_build_pocket = LaunchpadDropdownWidget
246+ custom_widget_auto_build_channels = SnapBuildChannelsWidget
247+ custom_widget_store_channels = StoreChannelsWidget
248
249 help_links = {
250 "auto_build_pocket": u"/+help-snappy/snap-build-pocket.html",
251
252=== modified file 'lib/lp/soyuz/browser/archive.py'
253--- lib/lp/soyuz/browser/archive.py 2018-05-11 17:52:11 +0000
254+++ lib/lp/soyuz/browser/archive.py 2018-09-13 08:25:30 +0000
255@@ -65,7 +65,6 @@
256 from lp.app.browser.badge import HasBadgeBase
257 from lp.app.browser.launchpadform import (
258 action,
259- custom_widget,
260 LaunchpadEditFormView,
261 LaunchpadFormView,
262 )
263@@ -830,8 +829,8 @@
264 """A Form view for filtering and batching source packages."""
265
266 schema = IPPAPackageFilter
267- custom_widget('series_filter', SeriesFilterWidget)
268- custom_widget('status_filter', StatusFilterWidget)
269+ custom_widget_series_filter = SeriesFilterWidget
270+ custom_widget_status_filter = StatusFilterWidget
271
272 # By default this view will not display the sources with selectable
273 # checkboxes, but subclasses can override as needed.
274@@ -1129,7 +1128,7 @@
275 class ArchiveSourceSelectionFormView(ArchiveSourcePackageListViewBase):
276 """Base class to implement a source selection widget for PPAs."""
277
278- custom_widget('selected_sources', LabeledMultiCheckBoxWidget)
279+ custom_widget_selected_sources = LabeledMultiCheckBoxWidget
280
281 selectable_sources = True
282
283@@ -1212,7 +1211,8 @@
284 """
285
286 schema = IArchivePackageDeletionForm
287- custom_widget('deletion_comment', StrippedTextWidget, displayWidth=50)
288+ custom_widget_deletion_comment = CustomWidgetFactory(
289+ StrippedTextWidget, displayWidth=50)
290 label = 'Delete packages'
291
292 @property
293@@ -1450,9 +1450,9 @@
294 a copying action that can be performed upon a set of selected packages.
295 """
296 schema = IPPAPackageFilter
297- custom_widget('destination_archive', DestinationArchiveDropdownWidget)
298- custom_widget('destination_series', DestinationSeriesDropdownWidget)
299- custom_widget('include_binaries', LaunchpadRadioWidget)
300+ custom_widget_destination_archive = DestinationArchiveDropdownWidget
301+ custom_widget_destination_series = DestinationSeriesDropdownWidget
302+ custom_widget_include_binaries = LaunchpadRadioWidget
303 label = 'Copy packages'
304
305 @property
306@@ -1615,12 +1615,13 @@
307
308 schema = IArchiveEditDependenciesForm
309
310- custom_widget('selected_dependencies', PlainMultiCheckBoxWidget,
311- cssClass='line-through-when-checked ppa-dependencies')
312- custom_widget('primary_dependencies', LaunchpadRadioWidget,
313- cssClass='highlight-selected')
314- custom_widget('primary_components', LaunchpadRadioWidget,
315- cssClass='highlight-selected')
316+ custom_widget_selected_dependencies = CustomWidgetFactory(
317+ PlainMultiCheckBoxWidget,
318+ cssClass='line-through-when-checked ppa-dependencies')
319+ custom_widget_primary_dependencies = CustomWidgetFactory(
320+ LaunchpadRadioWidget, cssClass='highlight-selected')
321+ custom_widget_primary_components = CustomWidgetFactory(
322+ LaunchpadRadioWidget, cssClass='highlight-selected')
323
324 label = "Edit PPA dependencies"
325 page_title = label
326@@ -1922,8 +1923,8 @@
327
328 schema = IArchive
329 field_names = ('name', 'displayname', 'description')
330- custom_widget('description', TextAreaWidget, height=3)
331- custom_widget('name', PPANameWidget, label="URL")
332+ custom_widget_description = CustomWidgetFactory(TextAreaWidget, height=3)
333+ custom_widget_name = CustomWidgetFactory(PPANameWidget, label="URL")
334 label = 'Activate a Personal Package Archive'
335 page_title = 'Activate PPA'
336
337@@ -2106,8 +2107,8 @@
338 'build_debug_symbols',
339 'publish_debug_symbols',
340 ]
341- custom_widget(
342- 'description', TextAreaWidget, height=10, width=30)
343+ custom_widget_description = CustomWidgetFactory(
344+ TextAreaWidget, height=10, width=30)
345 page_title = 'Change details'
346
347 @property
348@@ -2160,7 +2161,8 @@
349 'relative_build_score',
350 'external_dependencies',
351 ]
352- custom_widget('external_dependencies', TextAreaWidget, height=3)
353+ custom_widget_external_dependencies = CustomWidgetFactory(
354+ TextAreaWidget, height=3)
355 page_title = 'Administer'
356
357 @property
358
359=== modified file 'lib/lp/soyuz/browser/archivesubscription.py'
360--- lib/lp/soyuz/browser/archivesubscription.py 2015-09-24 11:30:01 +0000
361+++ lib/lp/soyuz/browser/archivesubscription.py 2018-09-13 08:25:30 +0000
362@@ -1,4 +1,4 @@
363-# Copyright 2009-2015 Canonical Ltd. This software is licensed under the
364+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
365 # GNU Affero General Public License version 3 (see the file LICENSE).
366
367 """Browser views related to archive subscriptions."""
368@@ -33,7 +33,6 @@
369 from lp import _
370 from lp.app.browser.launchpadform import (
371 action,
372- custom_widget,
373 LaunchpadEditFormView,
374 LaunchpadFormView,
375 )
376@@ -130,10 +129,10 @@
377
378 schema = IArchiveSubscriberUI
379 field_names = ['subscriber', 'date_expires', 'description']
380- custom_widget('description', TextWidget, displayWidth=40)
381- custom_widget('date_expires', CustomWidgetFactory(DateWidget))
382- custom_widget('subscriber', PersonPickerWidget,
383- header="Select the subscriber")
384+ custom_widget_description = CustomWidgetFactory(TextWidget, displayWidth=40)
385+ custom_widget_date_expires = DateWidget
386+ custom_widget_subscriber = CustomWidgetFactory(
387+ PersonPickerWidget, header="Select the subscriber")
388
389 @property
390 def label(self):
391@@ -245,8 +244,9 @@
392
393 schema = IArchiveSubscriberUI
394 field_names = ['date_expires', 'description']
395- custom_widget('description', TextWidget, displayWidth=40)
396- custom_widget('date_expires', CustomWidgetFactory(DateWidget))
397+ custom_widget_description = CustomWidgetFactory(
398+ TextWidget, displayWidth=40)
399+ custom_widget_date_expires = DateWidget
400
401 @property
402 def label(self):
403
404=== modified file 'lib/lp/soyuz/browser/livefs.py'
405--- lib/lp/soyuz/browser/livefs.py 2017-07-18 16:22:03 +0000
406+++ lib/lp/soyuz/browser/livefs.py 2018-09-13 08:25:30 +0000
407@@ -1,4 +1,4 @@
408-# Copyright 2014-2017 Canonical Ltd. This software is licensed under the
409+# Copyright 2014-2018 Canonical Ltd. This software is licensed under the
410 # GNU Affero General Public License version 3 (see the file LICENSE).
411
412 """LiveFS views."""
413@@ -29,7 +29,6 @@
414
415 from lp.app.browser.launchpadform import (
416 action,
417- custom_widget,
418 LaunchpadEditFormView,
419 LaunchpadFormView,
420 )
421@@ -210,7 +209,7 @@
422
423 schema = ILiveFSEditSchema
424 field_names = ['owner', 'name', 'distro_series', 'metadata']
425- custom_widget('distro_series', LaunchpadRadioWidget)
426+ custom_widget_distro_series = LaunchpadRadioWidget
427
428 def initialize(self):
429 """See `LaunchpadView`."""
430@@ -303,7 +302,7 @@
431 label = title
432
433 field_names = ['owner', 'name', 'distro_series', 'metadata']
434- custom_widget('distro_series', LaunchpadRadioWidget)
435+ custom_widget_distro_series = LaunchpadRadioWidget
436
437 @property
438 def initial_values(self):
439
440=== modified file 'lib/lp/translations/browser/hastranslationimports.py'
441--- lib/lp/translations/browser/hastranslationimports.py 2015-07-08 16:05:11 +0000
442+++ lib/lp/translations/browser/hastranslationimports.py 2018-09-13 08:25:30 +0000
443@@ -1,4 +1,4 @@
444-# Copyright 2009 Canonical Ltd. This software is licensed under the
445+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
446 # GNU Affero General Public License version 3 (see the file LICENSE).
447
448 """Browser view for IHasTranslationImports."""
449@@ -16,6 +16,7 @@
450 from z3c.ptcompat import ViewPageTemplateFile
451 from zope.component import getUtility
452 from zope.formlib import form
453+from zope.formlib.widget import CustomWidgetFactory
454 from zope.formlib.widgets import DropdownWidget
455 from zope.interface import implementer
456 from zope.schema import Choice
457@@ -28,7 +29,6 @@
458 from lp import _
459 from lp.app.browser.launchpadform import (
460 action,
461- custom_widget,
462 LaunchpadFormView,
463 safe_action,
464 )
465@@ -55,11 +55,14 @@
466 schema = IHasTranslationImports
467 field_names = []
468
469- custom_widget('filter_target', DropdownWidget, cssClass='inlined-widget')
470- custom_widget('filter_status', DropdownWidget, cssClass='inlined-widget')
471- custom_widget(
472- 'filter_extension', DropdownWidget, cssClass='inlined-widget')
473- custom_widget('status', DropdownWidget, cssClass='inlined-widget')
474+ custom_widget_filter_target = CustomWidgetFactory(
475+ DropdownWidget, cssClass='inlined-widget')
476+ custom_widget_filter_status = CustomWidgetFactory(
477+ DropdownWidget, cssClass='inlined-widget')
478+ custom_widget_filter_extension = CustomWidgetFactory(
479+ DropdownWidget, cssClass='inlined-widget')
480+ custom_widget_status = CustomWidgetFactory(
481+ DropdownWidget, cssClass='inlined-widget')
482
483 translation_import_queue_macros = ViewPageTemplateFile(
484 '../templates/translation-import-queue-macros.pt')
485@@ -88,7 +91,7 @@
486 __name__=name,
487 source=source,
488 title=_(title)),
489- custom_widget=self.custom_widgets[name],
490+ custom_widget=getattr(self, 'custom_widget_%s' % name),
491 render_context=self.render_context)
492
493 def createFilterStatusField(self):
494@@ -132,7 +135,7 @@
495 __name__=name,
496 source=EntryImportStatusVocabularyFactory(entry, self.user),
497 title=_('Select import status')),
498- custom_widget=self.custom_widgets['status'],
499+ custom_widget=self.custom_widgets_status,
500 render_context=self.render_context)
501
502 def setUpFields(self):
503
504=== modified file 'lib/lp/translations/browser/language.py'
505--- lib/lp/translations/browser/language.py 2013-04-10 08:09:05 +0000
506+++ lib/lp/translations/browser/language.py 2018-09-13 08:25:30 +0000
507@@ -1,4 +1,4 @@
508-# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
509+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
510 # GNU Affero General Public License version 3 (see the file LICENSE).
511
512 """Browser code for Language table."""
513@@ -16,6 +16,7 @@
514
515 from zope.component import getUtility
516 from zope.event import notify
517+from zope.formlib.widget import CustomWidgetFactory
518 from zope.formlib.widgets import TextWidget
519 from zope.interface import Interface
520 from zope.lifecycleevent import ObjectCreatedEvent
521@@ -23,7 +24,6 @@
522
523 from lp.app.browser.launchpadform import (
524 action,
525- custom_widget,
526 LaunchpadEditFormView,
527 LaunchpadFormView,
528 )
529@@ -120,7 +120,8 @@
530
531 schema = ILanguageSetSearch
532
533- custom_widget('search_lang', TextWidget, displayWidth=30)
534+ custom_widget_search_lang = CustomWidgetFactory(
535+ TextWidget, displayWidth=30)
536
537 def initialize(self):
538 """See `LaunchpadFormView`."""
539@@ -290,8 +291,8 @@
540
541 schema = ILanguage
542
543- custom_widget('countries', LabeledMultiCheckBoxWidget,
544- orientation='vertical')
545+ custom_widget_countries = CustomWidgetFactory(
546+ LabeledMultiCheckBoxWidget, orientation='vertical')
547
548 field_names = ['code', 'englishname', 'nativename', 'pluralforms',
549 'pluralexpression', 'visible', 'direction', 'countries']
550
551=== modified file 'lib/lp/translations/browser/person.py'
552--- lib/lp/translations/browser/person.py 2015-07-08 16:05:11 +0000
553+++ lib/lp/translations/browser/person.py 2018-09-13 08:25:30 +0000
554@@ -1,4 +1,4 @@
555-# Copyright 2009-2013 Canonical Ltd. This software is licensed under the
556+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
557 # GNU Affero General Public License version 3 (see the file LICENSE).
558
559 """Person-related translations view classes."""
560@@ -21,6 +21,7 @@
561 import pytz
562 from z3c.ptcompat import ViewPageTemplateFile
563 from zope.component import getUtility
564+from zope.formlib.widget import CustomWidgetFactory
565 from zope.formlib.widgets import TextWidget
566 from zope.interface import (
567 implementer,
568@@ -30,7 +31,6 @@
569 from lp import _
570 from lp.app.browser.launchpadform import (
571 action,
572- custom_widget,
573 LaunchpadFormView,
574 )
575 from lp.app.enums import ServiceUsage
576@@ -443,9 +443,9 @@
577 """View for Person's translation relicensing page."""
578 schema = ITranslationRelicensingAgreementEdit
579 field_names = ['allow_relicensing', 'back_to']
580- custom_widget(
581- 'allow_relicensing', LaunchpadRadioWidget, orientation='vertical')
582- custom_widget('back_to', TextWidget, visible=False)
583+ custom_widget_allow_relicensing = CustomWidgetFactory(
584+ LaunchpadRadioWidget, orientation='vertical')
585+ custom_widget_back_to = CustomWidgetFactory(TextWidget, visible=False)
586
587 page_title = "Licensing"
588
589
590=== modified file 'lib/lp/translations/browser/potemplate.py'
591--- lib/lp/translations/browser/potemplate.py 2016-09-12 15:07:45 +0000
592+++ lib/lp/translations/browser/potemplate.py 2018-09-13 08:25:30 +0000
593@@ -1,4 +1,4 @@
594-# Copyright 2009-2016 Canonical Ltd. This software is licensed under the
595+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
596 # GNU Affero General Public License version 3 (see the file LICENSE).
597 """Browser code for PO templates."""
598
599@@ -42,7 +42,6 @@
600 from lp import _
601 from lp.app.browser.launchpadform import (
602 action,
603- custom_widget,
604 LaunchpadEditFormView,
605 ReturnToReferrerMixin,
606 )
607@@ -524,7 +523,7 @@
608 else:
609 return IPOTemplate
610
611- custom_widget('sourcepackagename', POTemplateEditSourcePackageNameWidget)
612+ custom_widget_sourcepackagename = POTemplateEditSourcePackageNameWidget
613 label = 'Edit translation template details'
614 page_title = 'Edit details'
615 PRIORITY_MIN_VALUE = 0
616@@ -700,9 +699,9 @@
617 'from_sourcepackagename', 'sourcepackageversion',
618 'languagepack', 'path', 'source_file_format', 'priority',
619 'date_last_updated']
620- custom_widget('sourcepackagename', POTemplateAdminSourcePackageNameWidget)
621- custom_widget(
622- 'from_sourcepackagename', POTemplateAdminSourcePackageNameWidget)
623+ custom_widget_sourcepackagename = POTemplateAdminSourcePackageNameWidget
624+ custom_widget_from_sourcepackagename = (
625+ POTemplateAdminSourcePackageNameWidget)
626 label = 'Administer translation template'
627 page_title = "Administer"
628
629
630=== modified file 'lib/lp/translations/browser/productseries.py'
631--- lib/lp/translations/browser/productseries.py 2012-12-12 04:59:52 +0000
632+++ lib/lp/translations/browser/productseries.py 2018-09-13 08:25:30 +0000
633@@ -1,4 +1,4 @@
634-# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
635+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
636 # GNU Affero General Public License version 3 (see the file LICENSE).
637
638 """View classes for `IProductSeries`."""
639@@ -25,7 +25,6 @@
640 from lp import _
641 from lp.app.browser.launchpadform import (
642 action,
643- custom_widget,
644 LaunchpadEditFormView,
645 LaunchpadFormView,
646 ReturnToReferrerMixin,
647@@ -486,8 +485,7 @@
648 page_title = "Settings"
649
650 field_names = ['translations_autoimport_mode']
651- settings_widget = custom_widget('translations_autoimport_mode',
652- SettingsRadioWidget)
653+ custom_widget_translations_autoimport_mode = SettingsRadioWidget
654
655 @action(u"Save settings", name="save_settings")
656 def change_settings_action(self, action, data):
657
658=== modified file 'lib/lp/translations/browser/translationimportqueue.py'
659--- lib/lp/translations/browser/translationimportqueue.py 2016-09-12 17:41:21 +0000
660+++ lib/lp/translations/browser/translationimportqueue.py 2018-09-13 08:25:30 +0000
661@@ -1,4 +1,4 @@
662-# Copyright 2009-2016 Canonical Ltd. This software is licensed under the
663+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
664 # GNU Affero General Public License version 3 (see the file LICENSE).
665
666 """Browser views for `ITranslationImportQueue`."""
667@@ -27,7 +27,6 @@
668
669 from lp.app.browser.launchpadform import (
670 action,
671- custom_widget,
672 LaunchpadFormView,
673 )
674 from lp.app.browser.tales import DateTimeFormatterAPI
675@@ -113,8 +112,7 @@
676 else:
677 return IEditTranslationImportQueueEntry
678
679- custom_widget(
680- 'sourcepackagename',
681+ custom_widget_sourcepackagename = (
682 TranslationImportQueueEntrySourcePackageNameWidget)
683
684 max_series_to_display = 3