rearrange configuration stuff
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3494 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
687401d1ff
commit
8063d211a9
3 changed files with 54 additions and 22 deletions
|
@ -20,7 +20,7 @@ to make sure the btree-based tracking link manager will be used.
|
||||||
>>> manager = WikiManager()
|
>>> manager = WikiManager()
|
||||||
|
|
||||||
>>> linkManagerName = 'tracking'
|
>>> linkManagerName = 'tracking'
|
||||||
>>> manager.linkManager = linkManagerName
|
>>> manager.setConfig('linkManager', linkManagerName)
|
||||||
>>> wiki = manager.addWiki(Wiki('demo_wiki'))
|
>>> wiki = manager.addWiki(Wiki('demo_wiki'))
|
||||||
>>> startPage = wiki.createPage('start_page')
|
>>> startPage = wiki.createPage('start_page')
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,18 @@ $Id$
|
||||||
|
|
||||||
from zope.interface import implements
|
from zope.interface import implements
|
||||||
|
|
||||||
from cybertools.wiki.interfaces import IWikiConfiguration
|
from cybertools.wiki.interfaces import IWikiConfigInfo, IWikiConfiguration
|
||||||
|
|
||||||
|
|
||||||
|
class WikiConfigInfo(dict):
|
||||||
|
|
||||||
|
implements(IWikiConfigInfo)
|
||||||
|
|
||||||
|
def set(self, functionality, value):
|
||||||
|
self[functionality] = value
|
||||||
|
|
||||||
|
def __getattr__(self, attr):
|
||||||
|
return self.get(attr, None)
|
||||||
|
|
||||||
|
|
||||||
class BaseConfiguration(object):
|
class BaseConfiguration(object):
|
||||||
|
@ -33,31 +44,35 @@ class BaseConfiguration(object):
|
||||||
|
|
||||||
implements(IWikiConfiguration)
|
implements(IWikiConfiguration)
|
||||||
|
|
||||||
parent = None
|
_configInfo = None
|
||||||
|
|
||||||
writer = parser = None
|
|
||||||
|
|
||||||
def getConfig(self, functionality):
|
def getConfig(self, functionality):
|
||||||
c = self.get(functionality)
|
c = None
|
||||||
|
ci = self._configInfo
|
||||||
|
if ci is not None:
|
||||||
|
c = ci.get(functionality)
|
||||||
if c is None:
|
if c is None:
|
||||||
parent = self.getConfigParent()
|
parent = self.getConfigParent()
|
||||||
if parent is not None:
|
if parent is not None:
|
||||||
return parent.getConfig(functionality)
|
return parent.getConfig(functionality)
|
||||||
return c
|
return c
|
||||||
|
|
||||||
def get(self, key, default=None):
|
def setConfig(self, functionality, value):
|
||||||
return getattr(self, key, None)
|
if self._configInfo is None:
|
||||||
|
self._configInfo = WikiConfigInfo()
|
||||||
|
self._configInfo.set(functionality, value)
|
||||||
|
|
||||||
def getConfigParent(self):
|
def getConfigParent(self):
|
||||||
return self.parent
|
return None
|
||||||
|
|
||||||
|
|
||||||
class WikiConfiguration(BaseConfiguration):
|
class WikiConfiguration(BaseConfiguration):
|
||||||
""" A global utility providing the default settings.
|
""" A global utility providing the default settings.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
parser = 'docutils.rstx'
|
_configInfo = WikiConfigInfo(
|
||||||
writer = 'docutils.html'
|
parser='docutils.rstx',
|
||||||
linkManager = 'basic'
|
writer='docutils.html',
|
||||||
|
linkManager='basic',
|
||||||
nodeProcessors = dict(reference=['default'])
|
nodeProcessors=dict(reference=['default']),
|
||||||
|
)
|
||||||
|
|
|
@ -25,9 +25,8 @@ $Id$
|
||||||
from zope.interface import Interface, Attribute
|
from zope.interface import Interface, Attribute
|
||||||
|
|
||||||
|
|
||||||
class IWikiConfiguration(Interface):
|
class IWikiConfigInfo(Interface):
|
||||||
""" Provides information about the implementations to be used for
|
""" A collection of configuration settings.
|
||||||
the various kinds of wiki plug-ins.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
writer = Attribute('Plug-in component converting from internal tree '
|
writer = Attribute('Plug-in component converting from internal tree '
|
||||||
|
@ -35,16 +34,34 @@ class IWikiConfiguration(Interface):
|
||||||
parser = Attribute('Plug-in component converting from text input '
|
parser = Attribute('Plug-in component converting from text input '
|
||||||
'format to internal tree format.')
|
'format to internal tree format.')
|
||||||
|
|
||||||
def getConfigParent():
|
def get(functionality):
|
||||||
""" Return the parent object in case this configuration does not
|
""" Return the setting for the functionality given or None if not set.
|
||||||
provide configuration information for a certain functionality.
|
"""
|
||||||
|
|
||||||
|
def set(functionality, value):
|
||||||
|
""" Register the value given for the functionality given.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class IWikiConfiguration(Interface):
|
||||||
|
""" Provides information about the implementations to be used for
|
||||||
|
the various kinds of wiki plug-ins.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def getConfig(functionality):
|
def getConfig(functionality):
|
||||||
""" Return the name of the plugin that should used for the
|
""" Return the name of the component that should used for the
|
||||||
functionality given.
|
functionality given.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def setConfig(functionality, value):
|
||||||
|
""" Register the value given for the functionality given.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def getConfigParent():
|
||||||
|
""" Return the parent object in case this configuration does not
|
||||||
|
provide configuration information for a certain functionality.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
class IWikiManager(Interface):
|
class IWikiManager(Interface):
|
||||||
""" Manages wikis and wiki-related objects, like plugins.
|
""" Manages wikis and wiki-related objects, like plugins.
|
||||||
|
|
Loading…
Add table
Reference in a new issue