work in progress: construct base interfaces and sample base implementations
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3059 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
bef6db8f1d
commit
28b0abcf56
3 changed files with 44 additions and 25 deletions
|
@ -25,8 +25,7 @@ $Id$
|
|||
import re
|
||||
from zope.interface import implements
|
||||
|
||||
from cybertools.wiki.base.link import Link
|
||||
from cybertools.wiki.base.manager import SampleManager
|
||||
from cybertools.wiki.base.link import Link, LinkManager
|
||||
from cybertools.wiki.interfaces import IFormat, IFormatInstance
|
||||
|
||||
|
||||
|
@ -73,7 +72,7 @@ class BasicFormat(object):
|
|||
|
||||
def __init__(self, manager=None):
|
||||
if manager is None:
|
||||
manager = SampleManager()
|
||||
manager = LinkManager()
|
||||
self.manager = manager
|
||||
|
||||
def getInstance(self, context):
|
||||
|
|
|
@ -25,7 +25,34 @@ $Id$
|
|||
import re
|
||||
from zope.interface import implements
|
||||
|
||||
from cybertools.wiki.interfaces import ILink
|
||||
from cybertools.wiki.interfaces import ILink, ILinkManager
|
||||
|
||||
|
||||
class LinkManager(object):
|
||||
""" A very basic link manager implementation.
|
||||
"""
|
||||
|
||||
implements(ILinkManager)
|
||||
|
||||
def __init__(self):
|
||||
self.links = {}
|
||||
|
||||
def registerLink(self, link):
|
||||
if link.identifier is None:
|
||||
self.generateLinkIdentifier(link)
|
||||
if link.identifier not in self.links:
|
||||
self.links[link.identifier] = link
|
||||
link.manager = self
|
||||
|
||||
def unregisterLink(self, link):
|
||||
if link.identifier in self.links:
|
||||
del self.links[link.identifier]
|
||||
link.manager = None
|
||||
|
||||
def generateLinkIdentifier(self, link):
|
||||
identifier = 'l%07i' % (max(self.links.keys() or [0]) + 1)
|
||||
link.identifier = identifier
|
||||
return identifier
|
||||
|
||||
|
||||
class Link(object):
|
||||
|
|
|
@ -17,37 +17,30 @@
|
|||
#
|
||||
|
||||
"""
|
||||
A Wiki manager, i.e. a repository for pages and other information like
|
||||
links, images, etc.
|
||||
A Wiki manager managing wikis and wiki-related objects, esp plugins.
|
||||
|
||||
$Id$
|
||||
"""
|
||||
|
||||
from zope.interface import implements
|
||||
|
||||
from cybertools.wiki.interfaces import IWikiManager
|
||||
from cybertools.wiki.interfaces import IWikiManager, IWiki, IWikiPage
|
||||
|
||||
|
||||
class SampleManager(object):
|
||||
""" A very basic Wiki manager implementation.
|
||||
"""
|
||||
class WikiManager(object):
|
||||
|
||||
implements(IWikiManager)
|
||||
|
||||
def __init__(self):
|
||||
self.links = {}
|
||||
self.wikis = {}
|
||||
self.plugins = {}
|
||||
|
||||
def registerLink(self, link):
|
||||
if link.identifier is None:
|
||||
self.generateLinkIdentifier(link)
|
||||
if link.identifier not in self.links:
|
||||
self.links[link.identifier] = link
|
||||
link.manager = self
|
||||
|
||||
def unregisterLink(self, link):
|
||||
if link.identifier in self.links:
|
||||
del self.links[link.identifier]
|
||||
link.manager = None
|
||||
class Wiki(object):
|
||||
|
||||
def generateLinkIdentifier(self, link):
|
||||
identifier = 'l%07i' % (max(self.links.keys() or [0]) + 1)
|
||||
link.identifier = identifier
|
||||
return identifier
|
||||
implements(IWiki)
|
||||
|
||||
|
||||
class WikiPage(object):
|
||||
|
||||
implements(IWikiPage)
|
Loading…
Add table
Reference in a new issue