launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #00197
[Merge] lp:~salgado/launchpad/apidoc into lp:launchpad/devel
Guilherme Salgado has proposed merging lp:~salgado/launchpad/apidoc into lp:launchpad/devel.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Make zope.app.apidoc available on the new apidoc.lp.dev vhost.
--
https://code.launchpad.net/~salgado/launchpad/apidoc/+merge/30520
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~salgado/launchpad/apidoc into lp:launchpad/devel.
=== renamed file 'configs/development/apidoc-configure-normal.zcml.OFF' => 'configs/development/apidoc-configure-normal.zcml'
--- configs/development/apidoc-configure-normal.zcml.OFF 2008-09-02 16:03:35 +0000
+++ configs/development/apidoc-configure-normal.zcml 2010-07-21 12:31:21 +0000
@@ -1,48 +1,64 @@
<configure
xmlns="http://namespaces.zope.org/zope"
- xmlns:meta="http://namespaces.zope.org/meta">
+ xmlns:browser="http://namespaces.zope.org/browser"
+ xmlns:meta="http://namespaces.zope.org/meta"
+ xmlns:i18n="http://namespaces.zope.org/i18n"
+ i18n_domain="canonical">
<!-- These packages are required by apidoc. If they are deemed
generally useful, move them to zopeapp.zcml
-->
- <!--
- How frustrating. This is needed for just one page registration
- in introspector.zcml.
- -->
- <include package="zope.app" file="menus.zcml" />
- <include package="zope.app.tree.browser" />
- <include package="zope.app.tree" />
- <include package="zope.app.renderer" file="meta.zcml" />
+
+ <browser:menu
+ id="zmi_views"
+ title="Views"
+ description="Menu for displaying alternate representations of an object"
+ />
+ <browser:menu
+ id="zmi_actions"
+ title="Actions"
+ description="Menu for displaying actions to be performed"
+ />
+
+ <!-- XXX Probably make this in overrides for ISimpleReadContainer. Safer:
+ register for all apidoc containers, one way or another -->
+ <view
+ for="zope.container.interfaces.IReadContainer"
+ type="zope.publisher.interfaces.http.IHTTPRequest"
+ provides="zope.publisher.interfaces.IPublishTraverse"
+ factory="zope.container.traversal.ContainerTraverser"
+ permission="zope.Public"
+ allowed_interface="zope.publisher.interfaces.IPublishTraverse"
+ />
+ <adapter factory="canonical.launchpad.webapp.authentication.LaunchpadPrincipalAnnotations" />
+
+ <class class="canonical.launchpad.webapp.servers.LaunchpadBrowserRequest">
+ <implements interface="zope.app.apidoc.browser.skin.APIDOC" />
+ </class>
+
+ <!-- XXX: Copied from zope.browserresource as apidoc breaks if we make
+ IAPIDocRoot implement ISite so that the original registration works
+ for us. -->
+ <view
+ for="canonical.launchpad.webapp.interfaces.IAPIDocRoot"
+ type="zope.publisher.interfaces.browser.IDefaultBrowserLayer"
+ name=""
+ factory="zope.browserresource.resources.Resources"
+ permission="zope.Public"
+ allowed_interface="zope.publisher.interfaces.browser.IBrowserPublisher"
+ />
+
+ <!-- Turn on devmode for the following includes principal=work -->
+ <meta:provides feature="devmode" />
+
+ <include package="zope.location" />
+ <include package="zope.app.applicationcontrol" />
<include package="zope.app.renderer" />
-
- <!-- XXX: StuartBishop 2005-03-13 bug=39834:
- We also need the Z3 preference junk, whatever that is.
- Unfortunately, this depends on annotatable principals so will not
- currently work with Launchpad. We can still get some apidoc functionality,
- such as the ZCML browser, but the bulk of it is not functional.
- -->
<include package="zope.app.preference" file="meta.zcml" />
- <!--
+ <include package="zope.app.apidoc.codemodule" file="meta.zcml" />
+ <include package="zope.app.apidoc.bookmodule" file="meta.zcml" />
<include package="zope.app.preference" />
- -->
-
-
- <!-- Turn on devmode for the following includes principal=work -->
- <meta:provides feature="devmode" />
-
- <include package="zope.app.apidoc" file="meta.zcml" />
+ <include package="zope.app.tree" />
<include package="zope.app.apidoc" />
- <meta:redefinePermission
- from="zope.app.apidoc.UseAPIDoc" to="zope.Public"
- />
-
- <!-- Override a strange permission in apidoc -->
- <class class="zope.app.apidoc.apidoc.APIDocumentation">
- <require
- interface="zope.app.container.interfaces.IReadContainer"
- permission="zope.Public"
- />
- </class>
-
</configure>
=== modified file 'configs/development/launchpad-lazr.conf'
--- configs/development/launchpad-lazr.conf 2010-07-15 15:57:40 +0000
+++ configs/development/launchpad-lazr.conf 2010-07-21 12:31:21 +0000
@@ -300,6 +300,9 @@
[vhost.openid]
hostname: openid.launchpad.dev
+[vhost.apidoc]
+hostname: apidoc.launchpad.dev
+
[vhost.testopenid]
hostname: testopenid.dev
=== added symlink 'configs/testrunner/apidoc-configure-normal.zcml'
=== target is u'../development/apidoc-configure-normal.zcml'
=== modified file 'lib/canonical/config/schema-lazr.conf'
--- lib/canonical/config/schema-lazr.conf 2010-07-14 15:37:51 +0000
+++ lib/canonical/config/schema-lazr.conf 2010-07-21 12:31:21 +0000
@@ -1972,6 +1972,8 @@
[vhost.testopenid]
+[vhost.apidoc]
+
[vhost.ubuntu_openid]
[vhost.shipitubuntu]
=== modified file 'lib/canonical/configure.zcml'
--- lib/canonical/configure.zcml 2010-07-15 15:57:40 +0000
+++ lib/canonical/configure.zcml 2010-07-21 12:31:21 +0000
@@ -151,6 +151,12 @@
layer="canonical.launchpad.layers.AnswersLayer"
/>
+ <!-- virtual host: apidoc -->
+ <browser:defaultView
+ for="canonical.launchpad.webapp.interfaces.IAPIDocRoot"
+ name="++apidoc++"
+ />
+
<include package="canonical.widgets" />
<include package="canonical.launchpad" />
<include package="canonical.lazr" />
=== modified file 'lib/canonical/launchpad/browser/launchpad.py'
--- lib/canonical/launchpad/browser/launchpad.py 2010-07-14 13:54:20 +0000
+++ lib/canonical/launchpad/browser/launchpad.py 2010-07-21 12:31:21 +0000
@@ -62,8 +62,8 @@
stepto)
from canonical.launchpad.webapp.breadcrumb import Breadcrumb
from canonical.launchpad.webapp.interfaces import (
- GoneError, IBreadcrumb, ILaunchBag, ILaunchpadRoot, INavigationMenu,
- NotFoundError, POSTToNonCanonicalURL)
+ GoneError, IBreadcrumb, ILaunchBag, ILaunchpadRoot,
+ INavigationMenu, NotFoundError, POSTToNonCanonicalURL)
from canonical.launchpad.webapp.publisher import RedirectionView
from canonical.launchpad.webapp.authorization import check_permission
from canonical.launchpad.webapp.tales import PageTemplateContextsAPI
=== modified file 'lib/canonical/launchpad/doc/webapp-publication.txt'
--- lib/canonical/launchpad/doc/webapp-publication.txt 2010-03-02 03:22:01 +0000
+++ lib/canonical/launchpad/doc/webapp-publication.txt 2010-07-21 12:31:21 +0000
@@ -41,6 +41,10 @@
rooturl: http://api.launchpad.dev/
althosts:
----
+ apidoc @ apidoc.launchpad.dev
+ rooturl: http://apidoc.launchpad.dev/
+ althosts:
+ ----
blueprints @ blueprints.launchpad.dev
rooturl: http://blueprints.launchpad.dev/
althosts:
@@ -106,6 +110,7 @@
... print hostname
answers.launchpad.dev
api.launchpad.dev
+ apidoc.launchpad.dev
blueprints.launchpad.dev
bugs.launchpad.dev
code.launchpad.dev
=== modified file 'lib/canonical/launchpad/layers.py'
--- lib/canonical/launchpad/layers.py 2009-12-25 22:36:11 +0000
+++ lib/canonical/launchpad/layers.py 2010-07-21 12:31:21 +0000
@@ -57,6 +57,10 @@
"""
+class APIDocLayer(IBrowserRequest, IDefaultBrowserLayer):
+ """The `APIDocLayer` layer."""
+
+
class TestOpenIDLayer(LaunchpadLayer):
"""The `TestOpenIDLayer` layer."""
=== modified file 'lib/canonical/launchpad/permissions.zcml'
--- lib/canonical/launchpad/permissions.zcml 2009-11-15 01:05:49 +0000
+++ lib/canonical/launchpad/permissions.zcml 2010-07-21 12:31:21 +0000
@@ -85,5 +85,10 @@
title="Review Launchpad projects"
access_level="write" />
+ <!-- This permission only exists to please apidoc.launchpad.dev and
+ shouldn't be used anywhere else. -->
+ <permission
+ id="zope.ManageApplication" title="Needed by zope.app.apidoc"
+ access_level="read" />
</configure>
=== modified file 'lib/canonical/launchpad/security.py'
--- lib/canonical/launchpad/security.py 2010-07-20 12:33:43 +0000
+++ lib/canonical/launchpad/security.py 2010-07-21 12:31:21 +0000
@@ -1080,13 +1080,27 @@
class UseApiDoc(AuthorizationBase):
+ """This is just to please apidoc.launchpad.dev."""
permission = 'zope.app.apidoc.UseAPIDoc'
usedfor = Interface
+ def checkUnauthenticated(self):
+ return True
+
def checkAuthenticated(self, user):
return True
+class ManageApplicationForEverybody(UseApiDoc):
+ """This is just to please apidoc.launchpad.dev.
+
+ We do this because zope.app.apidoc uses that permission, but nothing else
+ should be using it.
+ """
+ permission = 'zope.ManageApplication'
+ usedfor = Interface
+
+
class OnlyBazaarExpertsAndAdmins(AuthorizationBase):
"""Base class that allows only the Launchpad admins and Bazaar
experts."""
=== modified file 'lib/canonical/launchpad/systemhomes.py'
--- lib/canonical/launchpad/systemhomes.py 2010-04-19 06:35:23 +0000
+++ lib/canonical/launchpad/systemhomes.py 2010-07-21 12:31:21 +0000
@@ -6,7 +6,7 @@
__all__ = [
'AuthServerApplication',
'BazaarApplication',
- 'CodeImportScheduler',
+ 'CodeImportSchedulerApplication',
'FeedsApplication',
'MailingListApplication',
'MaloneApplication',
@@ -39,7 +39,8 @@
from lp.hardwaredb.interfaces.hwdb import (
IHWDeviceSet, IHWDriverSet, IHWSubmissionDeviceSet, IHWSubmissionSet,
IHWVendorIDSet, ParameterError)
-from canonical.launchpad.webapp.interfaces import ICanonicalUrlData
+from canonical.launchpad.webapp.interfaces import (
+ IAPIDocRoot, ICanonicalUrlData)
from lp.bugs.interfaces.bug import (
CreateBugParams, IBugSet, InvalidBugTargetType)
from lp.code.interfaces.codehosting import ICodehostingApplication
@@ -388,3 +389,11 @@
class TestOpenIDApplication:
implements(ITestOpenIDApplication)
+
+
+class APIDocRoot:
+ implements(IAPIDocRoot)
+ __parent__ = None
+ __name__ = None
+
+apidocroot = APIDocRoot()
=== modified file 'lib/canonical/launchpad/webapp/authentication.py'
--- lib/canonical/launchpad/webapp/authentication.py 2010-02-16 14:25:51 +0000
+++ lib/canonical/launchpad/webapp/authentication.py 2010-07-21 12:31:21 +0000
@@ -19,9 +19,11 @@
from contrib.oauth import OAuthRequest
+from zope.annotation.interfaces import IAnnotations
from zope.interface import implements
-from zope.component import getUtility
+from zope.component import adapts, getUtility
from zope.event import notify
+from zope.preference.interfaces import IPreferenceGroup
from zope.security.proxy import removeSecurityProxy
@@ -320,6 +322,29 @@
return encryptor.validate(pw1, pw2)
+# zope.app.apidoc expects our principals to be adaptable into IAnnotations, so
+# we use this dummy adapter here just to make that code not OOPS.
+class LaunchpadPrincipalAnnotations:
+ implements(IAnnotations)
+ adapts(ILaunchpadPrincipal, IPreferenceGroup)
+
+ def __init__(self, principal, pref_group):
+ self.d = {}
+ pass
+
+ def __nonzero__(self):
+ return bool(self.d)
+
+ def __getitem__(self, key):
+ return self.d[key]
+
+ def get(self, key):
+ return self.d.get(key)
+
+ def __setitem__(self, key, value):
+ self.d[key] = value
+
+
def get_oauth_authorization(request):
"""Retrieve OAuth authorization information from a request.
=== modified file 'lib/canonical/launchpad/webapp/authorization.py'
--- lib/canonical/launchpad/webapp/authorization.py 2010-01-14 13:25:34 +0000
+++ lib/canonical/launchpad/webapp/authorization.py 2010-07-21 12:31:21 +0000
@@ -9,6 +9,7 @@
from zope.interface import classProvides
from zope.component import getUtility, queryAdapter
from zope.browser.interfaces import IView
+from zope.location.location import LocationProxy
from zope.publisher.interfaces import IApplicationRequest
from zope.security.interfaces import ISecurityPolicy
@@ -155,7 +156,16 @@
wd = participation.annotations.setdefault(
LAUNCHPAD_SECURITY_POLICY_CACHE_KEY,
weakref.WeakKeyDictionary())
- cache = wd.setdefault(objecttoauthorize, {})
+ try:
+ cache = wd.setdefault(objecttoauthorize, {})
+ except TypeError, e:
+ assert isinstance(objecttoauthorize, LocationProxy), (
+ "This try/except exists solely because "
+ "zope.app.apidoc will cause us to try and cache "
+ "LocationProxy objects, to which we can't have "
+ "weak refs. If we failed to cache anything else, "
+ "we need to re-evaluate this try/except.")
+ cache = {}
if permission in cache:
return cache[permission]
else:
=== modified file 'lib/canonical/launchpad/webapp/configure.zcml'
--- lib/canonical/launchpad/webapp/configure.zcml 2010-07-15 15:57:40 +0000
+++ lib/canonical/launchpad/webapp/configure.zcml 2010-07-21 12:31:21 +0000
@@ -33,6 +33,15 @@
factory="canonical.launchpad.webapp.publisher.CanonicalAbsoluteURL"
/>
+ <!-- Use the default IAbsoluteURL adapter for requests on the apidoc
+ vhost. -->
+ <adapter
+ for="zope.interface.Interface
+ canonical.launchpad.webapp.servers.APIDocBrowserRequest"
+ provides="zope.traversing.browser.interfaces.IAbsoluteURL"
+ factory="zope.traversing.browser.AbsoluteURL"
+ />
+
<adapter
for="zope.publisher.interfaces.http.IHTTPRequest"
provides="canonical.launchpad.webapp.interfaces.IDatabasePolicy"
@@ -672,6 +681,10 @@
permission="zope.Public"
class="canonical.launchpad.webapp.launchbag.LaunchBagView"
/>
+
+ <utility
+ component="canonical.launchpad.systemhomes.apidocroot"
+ provides="canonical.launchpad.webapp.interfaces.IAPIDocRoot" />
<!-- Resource unnamed view, allowing Z3 preferred spelling
/@@/launchpad-icon-small to access the images directory -->
=== modified file 'lib/canonical/launchpad/webapp/interfaces.py'
--- lib/canonical/launchpad/webapp/interfaces.py 2010-07-15 15:59:24 +0000
+++ lib/canonical/launchpad/webapp/interfaces.py 2010-07-21 12:31:21 +0000
@@ -65,6 +65,10 @@
"""
+class IAPIDocRoot(IContainmentRoot):
+ """Marker interface for the root object of the apidoc vhost."""
+
+
class ILaunchpadContainer(Interface):
"""Marker interface for objects used as the context of something."""
=== modified file 'lib/canonical/launchpad/webapp/publisher.py'
--- lib/canonical/launchpad/webapp/publisher.py 2010-03-15 17:17:05 +0000
+++ lib/canonical/launchpad/webapp/publisher.py 2010-07-21 12:31:21 +0000
@@ -544,9 +544,6 @@
class RootObject:
implements(ILaunchpadApplication, ILaunchpadRoot)
- # These next two needed by the Z3 API browser
- __parent__ = None
- __name__ = 'Launchpad'
rootObject = ProxyFactory(RootObject(), NamesChecker(["__class__"]))
=== modified file 'lib/canonical/launchpad/webapp/servers.py'
--- lib/canonical/launchpad/webapp/servers.py 2010-07-19 14:45:32 +0000
+++ lib/canonical/launchpad/webapp/servers.py 2010-07-21 12:31:21 +0000
@@ -61,7 +61,7 @@
from canonical.launchpad.webapp.notifications import (
NotificationRequest, NotificationResponse, NotificationList)
from canonical.launchpad.webapp.interfaces import (
- IBasicLaunchpadRequest, IBrowserFormNG,
+ IAPIDocRoot, IBasicLaunchpadRequest, IBrowserFormNG,
ILaunchpadBrowserApplicationRequest, ILaunchpadProtocolError,
INotificationRequest, INotificationResponse, IPlacelessAuthUtility,
IPlacelessLoginSource, OAuthPermission, UnexpectedFormData)
@@ -1129,6 +1129,16 @@
implements(canonical.launchpad.layers.FeedsLayer)
+# ---- apidoc
+
+class APIDocBrowserRequest(LaunchpadBrowserRequest):
+ implements(canonical.launchpad.layers.APIDocLayer)
+
+
+class APIDocBrowserPublication(LaunchpadBrowserPublication):
+ root_object_interface = IAPIDocRoot
+
+
# ---- testopenid
class TestOpenIDBrowserRequest(LaunchpadBrowserRequest):
@@ -1500,6 +1510,10 @@
factories.append(VHRP('testopenid', TestOpenIDBrowserRequest,
TestOpenIDBrowserPublication))
+ if config.devmode:
+ factories.append(
+ VHRP('apidoc', APIDocBrowserRequest, APIDocBrowserPublication))
+
# We may also have a private XML-RPC server.
private_port = None
for server in config.servers:
=== added file 'lib/lp/app/stories/apidoc.txt'
--- lib/lp/app/stories/apidoc.txt 1970-01-01 00:00:00 +0000
+++ lib/lp/app/stories/apidoc.txt 2010-07-21 12:31:21 +0000
@@ -0,0 +1,16 @@
+Launchpad's API docs
+====================
+
+It is generated by the zope.app.apidoc package, and can be seen on
+apidoc.launchpad.dev. (Note that this is just a smoke test)
+
+ >>> browser.open('http://apidoc.launchpad.dev')
+ >>> print extract_text(browser.contents)
+ Zope 3 API Documentation
+
+ >>> browser.open('http://apidoc.launchpad.dev/++apidoc++/contents.html')
+ >>> print extract_text(browser.contents)
+ Zope 3 apidoc...
+ Welcome to the Zope 3 API documentation tool...
+ Code Browser...
+ Interfaces...
=== modified file 'setup.py'
--- setup.py 2010-07-16 13:26:11 +0000
+++ setup.py 2010-07-21 12:31:21 +0000
@@ -70,6 +70,7 @@
'z3c.pt',
'z3c.ptcompat',
'zc.zservertracelog',
+ 'zope.app.apidoc',
'zope.app.appsetup',
'zope.app.component',
'zope.app.dav', # ./package-includes/dav-configure.zcml
@@ -77,7 +78,9 @@
'zope.app.exception',
'zope.app.file',
'zope.app.form',
+ 'zope.app.onlinehelp',
'zope.app.pagetemplate',
+ 'zope.app.preference',
'zope.app.publication',
'zope.app.publisher',
'zope.app.security',
@@ -85,6 +88,7 @@
'zope.app.server',
'zope.app.session',
'zope.app.testing',
+ 'zope.app.tree',
'zope.app.zcmlfiles',
'zope.app.wsgi',
'zope.app.zapi',
@@ -101,6 +105,7 @@
'zope.hookable', # indirect, via zope.app.component
'zope.lifecycleevent',
'zope.location',
+ 'zope.login',
'zope.pagetemplate',
'zope.publisher',
'zope.proxy',
=== modified file 'site.zcml'
--- site.zcml 2009-07-13 18:15:02 +0000
+++ site.zcml 2010-07-21 12:31:21 +0000
@@ -38,4 +38,5 @@
<include file="summarizerequests.zcml" />
<include package="zc.zservertracelog" />
+
</configure>
=== modified file 'versions.cfg'
--- versions.cfg 2010-07-16 13:26:11 +0000
+++ versions.cfg 2010-07-21 12:31:21 +0000
@@ -123,6 +123,7 @@
ZODB3 = 3.9.2
zodbcode = 3.4.0
zope.annotation = 3.5.0
+zope.app.apidoc = 3.7.3
zope.app.applicationcontrol = 3.5.1
zope.app.appsetup = 3.12.0
zope.app.authentication = 3.6.1
@@ -145,7 +146,10 @@
zope.app.interface = 3.5.0
zope.app.locales = 3.5.1
zope.app.localpermission = 3.7.0
+zope.app.onlinehelp = 3.5.2
zope.app.pagetemplate = 3.7.1
+zope.app.preference = 3.8.1
+zope.preference = 3.8.0
zope.app.principalannotation = 3.6.1
zope.app.publication = 3.9.0
zope.app.publisher = 3.10.0
@@ -158,6 +162,7 @@
# not in ZTK
zope.app.session = 3.6.0
zope.app.testing = 3.7.5
+zope.app.tree = 3.6.0
zope.app.wsgi = 3.6.0
# not in ZTK
zope.app.zapi = 3.4.1
@@ -197,6 +202,7 @@
zope.interface = 3.5.2
zope.lifecycleevent = 3.5.2
zope.location = 3.7.0
+zope.login = 1.0.0
zope.minmax = 1.1.1
zope.modulealias = 3.4.0
zope.pagetemplate = 3.5.0
@@ -206,7 +212,7 @@
zope.processlifetime = 1.0
zope.proxy = 3.5.0
zope.ptresource = 3.9.0
-zope.publisher = 3.10.0
+zope.publisher = 3.12.0
zope.schema = 3.5.4
zope.security = 3.7.1
zope.securitypolicy = 3.6.1
=== modified file 'zopeapp.zcml'
--- zopeapp.zcml 2009-07-13 18:15:02 +0000
+++ zopeapp.zcml 2010-07-21 12:31:21 +0000
@@ -25,6 +25,8 @@
<include package="zope.app.interface" />
<include package="zope.app.security" />
+ <include package="zope.login" />
+
<!--
<include package="zope.app.observable" />
<include package="zope.app.annotation" />