Skip to content

Commit

Permalink
Move applySkin from zope.app.publisher.browser to zope.publisher.brow…
Browse files Browse the repository at this point in the history
…ser.
  • Loading branch information
philikon committed Apr 4, 2006
1 parent 4a0f00a commit 2513468
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 0 deletions.
74 changes: 74 additions & 0 deletions apidoc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
##############################################################################
#
# Copyright (c) 2004 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Zope 3 API Documentation
$Id$
"""
__docformat__ = 'restructuredtext'

from zope.interface import implements
from zope.publisher.browser import applySkin

from zope.app import zapi
from zope.app.location import locate
from zope.app.location.interfaces import ILocation

from zope.app.apidoc.interfaces import IDocumentationModule
from zope.app.apidoc.utilities import ReadContainerBase

class APIDocumentation(ReadContainerBase):
"""Represent the complete API Documentation.
This documentation is implemented using a simply `IReadContainer`. The
items of the container are all registered utilities for
`IDocumentationModule`.
"""
implements(ILocation)

def __init__(self, parent, name):
self.__parent__ = parent
self.__name__ = name

def get(self, key, default=None):
"""See zope.app.container.interfaces.IReadContainer"""
utility = zapi.queryUtility(IDocumentationModule, key, default)
if utility != default:
locate(utility, self, key)
return utility

def items(self):
"""See zope.app.container.interfaces.IReadContainer"""
items = list(zapi.getUtilitiesFor(IDocumentationModule))
items.sort()
utils = []
for key, value in items:
locate(value, self, key)
utils.append((key, value))
return utils


class apidocNamespace(object):
"""Used to traverse to an API Documentation."""
def __init__(self, ob, request=None):
if request:
from zope.app.apidoc.browser.skin import APIDOC
applySkin(request, APIDOC)
self.context = ob

def traverse(self, name, ignore):
return handleNamespace(self.context, name)

def handleNamespace(ob, name):
"""Used to traverse to an API Documentation."""
return APIDocumentation(ob, '++apidoc++'+name)
42 changes: 42 additions & 0 deletions browser/preference.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""API Doc Preference Views
$Id$
"""
__docformat__ = "reStructuredText"

from zope.publisher.browser import applySkin

from zope.app import zapi
from zope.app.apidoc.browser.skin import APIDOC
from zope.app.tree.browser.cookie import CookieTreeView
from zope.app.preference.browser import PreferenceGroupFilter
from zope.app.preference.browser import EditPreferenceGroup

class APIDocPreferencesTree(CookieTreeView):
"""Preferences Tree using the stateful cookie tree."""

def apidocTree(self):
root = zapi.getRoot(self.context)['apidoc']
filter = PreferenceGroupFilter()
return self.cookieTree(root, filter)


class ApidocEditPreferenceGroup(EditPreferenceGroup):

def __init__(self, context, request):
# Make sure we enter APIDOC territory.
applySkin(request, APIDOC)
super(ApidocEditPreferenceGroup, self).__init__(context, request)

0 comments on commit 2513468

Please sign in to comment.