[Checkins] SVN: zwiki/branches/baijum-experimental-zwiki/ - Add
buildout support
Baiju M
baiju.m.mail at gmail.com
Fri Mar 23 07:57:37 EDT 2007
Log message for revision 73484:
- Add buildout support
- Re-organized package structure.
Changed:
D zwiki/branches/baijum-experimental-zwiki/CHANGES.txt
D zwiki/branches/baijum-experimental-zwiki/I18N.txt
D zwiki/branches/baijum-experimental-zwiki/INSTALL.txt
D zwiki/branches/baijum-experimental-zwiki/README.txt
A zwiki/branches/baijum-experimental-zwiki/README.txt
D zwiki/branches/baijum-experimental-zwiki/SETUP.cfg
D zwiki/branches/baijum-experimental-zwiki/__init__.py
A zwiki/branches/baijum-experimental-zwiki/bootstrap.py
D zwiki/branches/baijum-experimental-zwiki/browser/
A zwiki/branches/baijum-experimental-zwiki/buildout.cfg
D zwiki/branches/baijum-experimental-zwiki/comment.py
D zwiki/branches/baijum-experimental-zwiki/configure.zcml
D zwiki/branches/baijum-experimental-zwiki/diff.py
D zwiki/branches/baijum-experimental-zwiki/interfaces.py
D zwiki/branches/baijum-experimental-zwiki/locales/
A zwiki/branches/baijum-experimental-zwiki/setup.py
A zwiki/branches/baijum-experimental-zwiki/src/
A zwiki/branches/baijum-experimental-zwiki/src/zwiki/
A zwiki/branches/baijum-experimental-zwiki/src/zwiki/CHANGES.txt
A zwiki/branches/baijum-experimental-zwiki/src/zwiki/I18N.txt
A zwiki/branches/baijum-experimental-zwiki/src/zwiki/INSTALL.txt
A zwiki/branches/baijum-experimental-zwiki/src/zwiki/README.txt
A zwiki/branches/baijum-experimental-zwiki/src/zwiki/__init__.py
A zwiki/branches/baijum-experimental-zwiki/src/zwiki/browser/
A zwiki/branches/baijum-experimental-zwiki/src/zwiki/comment.py
A zwiki/branches/baijum-experimental-zwiki/src/zwiki/configure.zcml
A zwiki/branches/baijum-experimental-zwiki/src/zwiki/diff.py
A zwiki/branches/baijum-experimental-zwiki/src/zwiki/interfaces.py
A zwiki/branches/baijum-experimental-zwiki/src/zwiki/locales/
A zwiki/branches/baijum-experimental-zwiki/src/zwiki/tests/
A zwiki/branches/baijum-experimental-zwiki/src/zwiki/traversal.py
A zwiki/branches/baijum-experimental-zwiki/src/zwiki/wiki.py
A zwiki/branches/baijum-experimental-zwiki/src/zwiki/wikipage.py
A zwiki/branches/baijum-experimental-zwiki/src/zwiki/zwiki-configure.zcml
D zwiki/branches/baijum-experimental-zwiki/tests/
D zwiki/branches/baijum-experimental-zwiki/traversal.py
D zwiki/branches/baijum-experimental-zwiki/wiki.py
D zwiki/branches/baijum-experimental-zwiki/wikipage.py
D zwiki/branches/baijum-experimental-zwiki/zwiki-configure.zcml
-=-
Deleted: zwiki/branches/baijum-experimental-zwiki/CHANGES.txt
===================================================================
--- zwiki/branches/baijum-experimental-zwiki/CHANGES.txt 2007-03-23 09:29:55 UTC (rev 73483)
+++ zwiki/branches/baijum-experimental-zwiki/CHANGES.txt 2007-03-23 11:57:36 UTC (rev 73484)
@@ -1,24 +0,0 @@
-CHANGES
-
- Version 0.2.5
-
- - Added translations.
-
- Version 0.2
-
- - Moved from zope.app.wiki to wiki.
-
- Version 0.1.0
-
- - Since Indices and ObjectHub are not part of Zope X3.0, I removed the
- index-based search and replaced it by a very primitive one.
-
- - Removed old disgusting comment support, and made the wiki page a
- container which can contain comments.
-
- - Fixed browser views according to the new implementations.
-
-
- Version 0.0.1
-
- - Initial version of Zope3 Wiki
Deleted: zwiki/branches/baijum-experimental-zwiki/I18N.txt
===================================================================
--- zwiki/branches/baijum-experimental-zwiki/I18N.txt 2007-03-23 09:29:55 UTC (rev 73483)
+++ zwiki/branches/baijum-experimental-zwiki/I18N.txt 2007-03-23 11:57:36 UTC (rev 73484)
@@ -1,37 +0,0 @@
-===================================================
-Internationalization (I18n) and Localization (L10n)
-===================================================
-
-Creating/Updating Message Catalog Template (POT) Files
-------------------------------------------------------
-
-1. Install `zwiki` in `ZOPE3/src`. See `INSTALL.txt` for details.
-
-2. Set the the Python path::
-
- export PYTHONPATH=ZOPE3/src
-
-3. Go into the `locales` directory and execute `i18nextract.py`::
-
- python2.4 utilities/i18nextract.py -d zwiki -p ..
-
-
-Updating Message Catalog (PO) Files
------------------------------------
-
-1. For each language do simply::
-
- msgmerge -U de/LC_MESSAGES/zwiki.po zwiki.pot
-
-2. Translate the updated PO file.
- Note: KBabel is a great tool for this task!
-
-
-Compiling Message Catalogs (PO) to binary (MO) Files
-----------------------------------------------------
-
-1. Go to the right directory, such as `<zwiki>/locales/de/LC_MESSAGES`.
-
-2. Run the following command::
-
- msgfmt -o zwiki.mo zwiki.po
Deleted: zwiki/branches/baijum-experimental-zwiki/INSTALL.txt
===================================================================
--- zwiki/branches/baijum-experimental-zwiki/INSTALL.txt 2007-03-23 09:29:55 UTC (rev 73483)
+++ zwiki/branches/baijum-experimental-zwiki/INSTALL.txt 2007-03-23 11:57:36 UTC (rev 73484)
@@ -1,29 +0,0 @@
-Installation
-============
-
- - Since Wiki is not enabled by default, you need to include the Wiki
- package in your instance's configuration. Create
- $INSTANCE_HOME/package-includes/zwiki-configure by copying the file
- package-includes/zwiki-configure.zcml from the Zope repository, or create
- it with the following contents::
-
- <include package="zwiki" />
-
- - You need to define the following role declarations to your user in order
- to use the wiki package effectively::
-
- <grant role="zwiki.Admin" principal="user" />
- <grant role="zwiki.Editor" principal="user" />
- <grant role="zwiki.User" principal="user" />
-
- <grant role="zwiki.User" principal="anybody" />
-
-Usage
-=====
-
- 1. To see Wikis in action, go into the management interface and add a Wiki
- object named 'wiki'. Leave the two preselected options.
-
- 2. To enter the end user interface, enter::
-
- http://localhost:8080/++skin++wiki/wiki
Deleted: zwiki/branches/baijum-experimental-zwiki/README.txt
===================================================================
--- zwiki/branches/baijum-experimental-zwiki/README.txt 2007-03-23 09:29:55 UTC (rev 73483)
+++ zwiki/branches/baijum-experimental-zwiki/README.txt 2007-03-23 11:57:36 UTC (rev 73484)
@@ -1,50 +0,0 @@
-ZWiki for Zope 3
-================
-
-This product is a port/rewrite of the famous Zope 2 product Zwiki. At
-the current stage only the most basic Wiki functionalities are
-implemented and much more work needs to be done.
-
-Features
---------
-
-Rendering
-
- - Plain Text
-
- - Structured Text
-
- - reStructured Text (reST)
-
-
-Wiki
-
- - Table of Contents
-
- - Mail Subscription for entire Wiki
-
- - Full-text Search
-
-
-Wiki Page
-
- - Proper rendering of Wiki Links
-
- - Edit Wiki Page
-
- - Comment on a Wiki Page
-
- - Declare Wiki Hierarchy (Parents)
-
- - Local, WikiPage-based Mail Subscription
-
- - Jumping to other Wikis
-
-
-Miscellaneous
-
- - Somewhat sophisticated rendering mechanism. New source types and
- their render methods can now be configured (added) via ZCML.
-
- - A fully independent skin called 'wiki'; Note that this skin will
- be only useful in the context of a Wiki Page.
Added: zwiki/branches/baijum-experimental-zwiki/README.txt
===================================================================
--- zwiki/branches/baijum-experimental-zwiki/README.txt 2007-03-23 09:29:55 UTC (rev 73483)
+++ zwiki/branches/baijum-experimental-zwiki/README.txt 2007-03-23 11:57:36 UTC (rev 73484)
@@ -0,0 +1,50 @@
+ZWiki for Zope 3
+================
+
+This product is a port/rewrite of the famous Zope 2 product Zwiki. At
+the current stage only the most basic Wiki functionalities are
+implemented and much more work needs to be done.
+
+Features
+--------
+
+Rendering
+
+ - Plain Text
+
+ - Structured Text
+
+ - reStructured Text (reST)
+
+
+Wiki
+
+ - Table of Contents
+
+ - Mail Subscription for entire Wiki
+
+ - Full-text Search
+
+
+Wiki Page
+
+ - Proper rendering of Wiki Links
+
+ - Edit Wiki Page
+
+ - Comment on a Wiki Page
+
+ - Declare Wiki Hierarchy (Parents)
+
+ - Local, WikiPage-based Mail Subscription
+
+ - Jumping to other Wikis
+
+
+Miscellaneous
+
+ - Somewhat sophisticated rendering mechanism. New source types and
+ their render methods can now be configured (added) via ZCML.
+
+ - A fully independent skin called 'wiki'; Note that this skin will
+ be only useful in the context of a Wiki Page.
Property changes on: zwiki/branches/baijum-experimental-zwiki/README.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Deleted: zwiki/branches/baijum-experimental-zwiki/SETUP.cfg
===================================================================
--- zwiki/branches/baijum-experimental-zwiki/SETUP.cfg 2007-03-23 09:29:55 UTC (rev 73483)
+++ zwiki/branches/baijum-experimental-zwiki/SETUP.cfg 2007-03-23 11:57:36 UTC (rev 73484)
@@ -1,5 +0,0 @@
-# Tell zpkg how to install the ZCML slugs.
-
-<data-files zopeskel/etc/package-includes>
- zwiki-*.zcml
-</data-files>
Deleted: zwiki/branches/baijum-experimental-zwiki/__init__.py
===================================================================
--- zwiki/branches/baijum-experimental-zwiki/__init__.py 2007-03-23 09:29:55 UTC (rev 73483)
+++ zwiki/branches/baijum-experimental-zwiki/__init__.py 2007-03-23 11:57:36 UTC (rev 73484)
@@ -1,23 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 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.
-#
-##############################################################################
-"""ZWiki for Zope 3
-
-$Id$
-"""
-from zope.i18nmessageid import MessageFactory
-ZWikiMessageFactory = MessageFactory("zwiki")
-
-# BBB
-import sys
-sys.modules['zope.app.wiki'] = sys.modules[__name__]
Added: zwiki/branches/baijum-experimental-zwiki/bootstrap.py
===================================================================
--- zwiki/branches/baijum-experimental-zwiki/bootstrap.py 2007-03-23 09:29:55 UTC (rev 73483)
+++ zwiki/branches/baijum-experimental-zwiki/bootstrap.py 2007-03-23 11:57:36 UTC (rev 73484)
@@ -0,0 +1,52 @@
+##############################################################################
+#
+# Copyright (c) 2006 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.
+#
+##############################################################################
+"""Bootstrap a buildout-based project
+
+Simply run this script in a directory containing a buildout.cfg.
+The script accepts buildout command-line options, so you can
+use the -c option to specify an alternate configuration file.
+
+$Id: bootstrap.py 73331 2007-03-19 09:00:31Z baijum $
+"""
+
+import os, shutil, sys, tempfile, urllib2
+
+tmpeggs = tempfile.mkdtemp()
+
+ez = {}
+exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+ ).read() in ez
+ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+
+import pkg_resources
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+if sys.platform == 'win32':
+ cmd = '"%s"' % cmd # work around spawn lamosity on windows
+
+ws = pkg_resources.working_set
+assert os.spawnle(
+ os.P_WAIT, sys.executable, sys.executable,
+ '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
+ dict(os.environ,
+ PYTHONPATH=
+ ws.find(pkg_resources.Requirement.parse('setuptools')).location
+ ),
+ ) == 0
+
+ws.add_entry(tmpeggs)
+ws.require('zc.buildout')
+import zc.buildout.buildout
+zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
+shutil.rmtree(tmpeggs)
Property changes on: zwiki/branches/baijum-experimental-zwiki/bootstrap.py
___________________________________________________________________
Name: svn:eol-style
+ native
Added: zwiki/branches/baijum-experimental-zwiki/buildout.cfg
===================================================================
--- zwiki/branches/baijum-experimental-zwiki/buildout.cfg 2007-03-23 09:29:55 UTC (rev 73483)
+++ zwiki/branches/baijum-experimental-zwiki/buildout.cfg 2007-03-23 11:57:36 UTC (rev 73484)
@@ -0,0 +1,81 @@
+[buildout]
+develop = .
+parts = zwikiapp instance test
+
+find-links = http://download.zope.org/distribution/
+
+[zope3]
+location =
+
+[zwikiapp]
+recipe = zc.zope3recipes:app
+site.zcml = <include package="zope.app.securitypolicy" file="meta.zcml" />
+ <include package="zope.sendmail" file="meta.zcml"/>
+ <include package="zope.app.layers" file="meta.zcml" />
+
+ <include package="zope.app.zcmlfiles" />
+ <include package="zope.app.authentication" />
+ <include package="zope.app.securitypolicy" />
+ <include package="zope.app.twisted" />
+ <include package="zope.sendmail" />
+ <include package="zope.app.zptpage"/>
+ <include package="zwiki" />
+
+ <securityPolicy
+ component="zope.app.securitypolicy.zopepolicy.ZopeSecurityPolicy" />
+
+ <role id="zope.Anonymous" title="Everybody"
+ description="All users have this role implicitly" />
+ <role id="zope.Manager" title="Site Manager" />
+ <role id="zope.Member" title="Site Member" />
+
+ <!-- Replace the following directive if you don't want public access -->
+ <grant permission="zope.View"
+ role="zope.Anonymous" />
+ <grant permission="zope.app.dublincore.view"
+ role="zope.Anonymous" />
+
+ <grantAll role="zope.Manager" />
+
+ <unauthenticatedPrincipal
+ id="zope.anybody"
+ title="Unauthenticated User" />
+
+ <unauthenticatedGroup
+ id="zope.Anybody"
+ title="Unauthenticated Users" />
+
+ <authenticatedGroup
+ id="zope.Authenticated"
+ title="Authenticated Users" />
+
+ <everybodyGroup
+ id="zope.Everybody"
+ title="All Users" />
+
+ <principal
+ id="zope.manager"
+ title="Manager"
+ login="admin"
+ password_manager="Plain Text"
+ password="admin"
+ />
+
+ <grant
+ role="zope.Manager"
+ principal="zope.manager" />
+
+eggs = zwiki
+
+[instance]
+recipe = zc.zope3recipes:instance
+application = zwikiapp
+zope.conf = ${database:zconfig}
+
+[database]
+recipe = zc.recipe.filestorage
+
+[test]
+recipe = zc.recipe.testrunner
+defaults = ['--tests-pattern', '^f?tests$', '-u']
+eggs = zwiki
Property changes on: zwiki/branches/baijum-experimental-zwiki/buildout.cfg
___________________________________________________________________
Name: svn:eol-style
+ native
Deleted: zwiki/branches/baijum-experimental-zwiki/comment.py
===================================================================
--- zwiki/branches/baijum-experimental-zwiki/comment.py 2007-03-23 09:29:55 UTC (rev 73483)
+++ zwiki/branches/baijum-experimental-zwiki/comment.py 2007-03-23 11:57:36 UTC (rev 73484)
@@ -1,207 +0,0 @@
-##############################################################################
-#
-# 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.
-#
-##############################################################################
-"""WikiPage Comment
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from persistent import Persistent
-
-from zope.interface import implements
-from zope.schema.vocabulary import getVocabularyRegistry
-from zope.dublincore.interfaces import ICMFDublinCore
-from zope.app.container.contained import Contained
-from zope.filerepresentation.interfaces import IReadFile, IWriteFile
-
-from zwiki.interfaces import IComment
-from zwiki.interfaces import IWikiPageContained
-
-
-class Comment(Persistent, Contained):
- r"""A simple persistent comment implementation.
-
- The comment is really a primitive object, since it only declares a couple
- of attributes. The only thing interesting here is the title, which
- retrieved from its Dublin Core value.
-
- First off let's make sure that we actually implement the interface:
-
- >>> comment = Comment()
- >>> IComment.providedBy(comment)
- True
-
- Now, verify that the attributes are set correctly.
-
- >>> comment.source
- u''
- >>> comment.source = u'comment 1'
- >>> comment.source
- u'comment 1'
-
- >>> comment.type
- u'zope.source.rest'
- >>> comment.type = u'zope.source.stx'
- >>> comment.type
- u'zope.source.stx'
-
- >>> comment.title
- u''
- >>> comment.title = u'C1'
- >>> comment.title
- u'C1'
-
- (Note: The comment is not responsible for checking the validity of the
- type.)
-
- """
- implements(IComment, IWikiPageContained)
-
- # See wiki.interfaces.IComment
- source = u''
-
- # See wiki.interfaces.IComment
- type = u'zope.source.rest'
-
- # See wiki.interfaces.IComment
- def _getTitle(self):
- dc = ICMFDublinCore(self)
- return dc.title
-
- def _setTitle(self, title):
- dc = ICMFDublinCore(self)
- dc.title = title
-
- title = property(_getTitle, _setTitle)
-
-
-# Adapters for file-system style access
-
-class CommentFile:
- r"""Adapter for letting a Comment look like a regular readable file.
-
- Example of Usage:
-
- >>> comment = Comment()
- >>> comment.title = u'Comment 1'
- >>> comment.source = u'This is a comment'
- >>> file = CommentFile(comment)
-
- Now let's see whether we can read the comment file.
-
- >>> file.read()
- u'Title: Comment 1\nType: zope.source.rest\n\nThis is a comment'
-
- And that the size of the file is correct:
-
- >>> file.size()
- 58
-
- Let's see whether we can also write to a file correctly:
-
- >>> file.write('Title: C1\nType: zope.source.stx\n\ncomment 1')
- >>> comment.title
- u'C1'
- >>> comment.type
- u'zope.source.stx'
- >>> comment.source
- u'comment 1'
-
- Sometimes the user might not have entered a valid type; let's ignore the
- assignment then.
-
- >>> file.write('Type: zope.source.foo\n\ncomment 2')
- >>> comment.title
- u'C1'
- >>> comment.type
- u'zope.source.stx'
- >>> comment.source
- u'comment 2'
-
- In the previous example the title was missing, but the type is optional
- too:
-
- >>> file.write('Title: C3\n\ncomment 3')
- >>> comment.title
- u'C3'
- >>> comment.type
- u'zope.source.stx'
- >>> comment.source
- u'comment 3'
- """
-
- implements(IReadFile, IWriteFile)
- __used_for__ = IComment
-
- def __init__(self, context):
- self.context = context
-
- def read(self):
- """See zope.filerepresentation.interfaces.IReadFile"""
- text = 'Title: %s\n' %self.context.title
- text += 'Type: %s\n\n' %self.context.type
- text += self.context.source
- return text
-
- def size(self):
- """See zope.filerepresentation.interfaces.IReadFile"""
- return len(self.read())
-
- def write(self, data):
- """See zope.filerepresentation.interfaces.IWriteFile"""
- if data.startswith('Title: '):
- title, data = data.split('\n', 1)
- self.context.title = unicode(title[7:])
-
- if data.startswith('Type: '):
- type, data = data.split('\n', 1)
- type = type[6:]
- vocab = getVocabularyRegistry().get(self.context, 'SourceTypes')
- if type in [term.value for term in vocab]:
- self.context.type = unicode(type)
-
- if data.startswith('\n'):
- data = data[1:]
-
- self.context.source = unicode(data)
-
-
-class CommentFileFactory(object):
- r"""A factory that creates a comment.
-
- This component is used by the WikiPage file representation. If you add a
- file to a wiki page, then it is interpreted as adding a comment to the
- wiki page.
-
- Usage:
-
- >>> factory = CommentFileFactory(None)
- >>> comment = factory('foo' ,'',
- ... 'Title: C1\nType: zope.source.stx\n\nComment 1')
- >>> comment.title
- u'C1'
- >>> comment.type
- u'zope.source.stx'
- >>> comment.source
- u'Comment 1'
- """
-
- def __init__(self, context):
- """Initialize the object."""
-
- def __call__(self, name, content_type, data):
- """The comment is created from the provided information."""
- comment = Comment()
- CommentFile(comment).write(data)
- return comment
Deleted: zwiki/branches/baijum-experimental-zwiki/configure.zcml
===================================================================
--- zwiki/branches/baijum-experimental-zwiki/configure.zcml 2007-03-23 09:29:55 UTC (rev 73483)
+++ zwiki/branches/baijum-experimental-zwiki/configure.zcml 2007-03-23 11:57:36 UTC (rev 73484)
@@ -1,293 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:mail="http://namespaces.zope.org/mail"
- xmlns:i18n="http://namespaces.zope.org/i18n"
- xmlns:apidoc="http://namespaces.zope.org/apidoc"
- xmlns:zcml="http://namespaces.zope.org/zcml"
- i18n_domain="zwiki"
- >
-
- <!-- Security definitions -->
-
- <role
- id="zwiki.User"
- title="Wiki User"
- description="Wiki visitors, which can only view and comment on wikis." />
-
- <role
- id="zwiki.Editor"
- title="Wiki Editor"
- description="The Wiki Editor can create and edit wikis." />
-
- <role
- id="zwiki.Admin"
- title="Wiki Administrator"
- description="The Wiki Admin can fully manage wiki pages." />
-
- <permission
- id="zwiki.ViewWikiPage"
- title="View Wiki Page"
- description="View a Wiki Page" />
-
- <grant
- permission="zwiki.ViewWikiPage"
- role="zwiki.User" />
-
- <permission
- id="zwiki.CommentWikiPage"
- title="Comment on Wiki Page"
- description="Make a comment on Wiki Page" />
-
- <grant
- permission="zwiki.CommentWikiPage"
- role="zwiki.User" />
-
- <permission
- id="zwiki.AddWikiPage"
- title="Add Wiki Page"
- description="Add Wiki Page" />
-
- <grant
- permission="zwiki.AddWikiPage"
- role="zwiki.Editor" />
-
- <permission
- id="zwiki.EditWikiPage"
- title="Edit Wiki Page"
- description="Edit Wiki Page" />
-
- <grant
- permission="zwiki.EditWikiPage"
- role="zwiki.Editor" />
-
- <permission
- id="zwiki.DeleteWikiPage"
- title="Delete Wiki Page"
- description="Delete Wiki Page" />
-
- <grant
- permission="zwiki.DeleteWikiPage"
- role="zwiki.Admin" />
-
- <permission
- id="zwiki.ReparentWikiPage"
- title="Reparent Wiki Page"
- description="Reparent a Wiki Page" />
-
- <grant
- permission="zwiki.ReparentWikiPage"
- role="zwiki.Admin"/>
-
-
- <!-- Content declarations -->
-
- <interface
- interface=".interfaces.IWiki"
- type="zope.app.content.interfaces.IContentType"
- />
-
- <class class=".wiki.Wiki">
-
- <implements
- interface="zope.annotation.interfaces.IAttributeAnnotatable" />
-
- <factory
- id="zwiki.Wiki"
- description="Minimal Wiki Page Container implementation " />
-
- <allow
- attributes="getSiteManager"
- />
-
- <require
- permission="zope.ManageServices"
- attributes="setSiteManager"
- />
-
- <require
- permission="zope.View"
- interface="zope.app.container.interfaces.IReadContainer"/>
-
- <require
- permission="zwiki.AddWikiPage"
- interface="zope.app.container.interfaces.IWriteContainer"/>
-
- </class>
-
- <!-- Mail Subscriptions support -->
- <adapter
- factory=".wikipage.MailSubscriptions"
- provides=".interfaces.IMailSubscriptions"
- for=".interfaces.IWiki"
- trusted="true"
- />
-
- <class class=".wikipage.MailSubscriptions">
- <require
- permission="zwiki.EditWikiPage"
- attributes="getSubscriptions"
- />
- <require
- permission="zwiki.EditWikiPage"
- attributes="addSubscriptions removeSubscriptions"
- />
- </class>
-
-
- <!-- Wiki Page Content Type -->
-
- <interface
- interface=".interfaces.IWikiPage"
- type="zope.app.content.interfaces.IContentType"
- />
-
- <class class=".wikipage.WikiPage">
-
- <implements
- interface="zope.annotation.interfaces.IAttributeAnnotatable" />
-
- <factory
- id="zwiki.WikiPage"
- title="Wiki Page"
- description="A Wiki Page" />
-
- <allow interface=".interfaces.IWikiPage" />
-
-
- <require
- permission="zwiki.AddWikiPage"
- set_schema=".interfaces.IWikiPage" />
-
- </class>
-
- <adapter
- factory=".wikipage.WikiPageHierarchyAdapter"
- provides=".interfaces.IWikiPageHierarchy"
- for=".interfaces.IWikiPage"
- trusted="true"
- locate="true" />
-
- <class class=".wikipage.WikiPageHierarchyAdapter">
- <require
- permission="zwiki.ViewWikiPage"
- attributes="parents path findChildren"
- />
- <require
- permission="zwiki.ReparentWikiPage"
- attributes="reparent"
- set_attributes="parents"
- />
- </class>
-
- <!-- Wiki Comments support -->
-
- <interface
- interface=".interfaces.IComment"
- type="zope.app.content.interfaces.IContentType"
- />
-
- <class class=".comment.Comment">
-
- <implements
- interface="zope.annotation.interfaces.IAttributeAnnotatable" />
-
- <factory
- id="zwiki.Comment"
- title="Wiki Page Comment"
- description="A Wiki Page Comment" />
-
- <allow interface=".interfaces.IComment" />
-
- <require
- permission="zwiki.CommentWikiPage"
- set_schema=".interfaces.IComment" />
-
- </class>
-
- <adapter
- for=".interfaces.IComment"
- provides="zope.filerepresentation.interfaces.IReadFile"
- factory=".comment.CommentFile"
- permission="zwiki.ViewWikiPage"
- />
-
- <adapter
- for=".interfaces.IComment"
- provides="zope.filerepresentation.interfaces.IWriteFile"
- factory=".comment.CommentFile"
- permission="zwiki.CommentWikiPage"
- />
-
-
- <!-- Mail Subscriptions support -->
- <adapter
- factory=".wikipage.MailSubscriptions"
- provides=".interfaces.IMailSubscriptions"
- for=".interfaces.IWikiPage"
- trusted="true"
- />
-
- <adapter
- factory=".traversal.WikiPageTraversable"
- provides="zope.traversing.interfaces.ITraversable"
- for=".interfaces.IWikiPage"
- trusted="true"
- />
-
-
- <!-- WikiPage FTP configurations -->
- <adapter
- for=".interfaces.IWikiPage"
- provides="zope.filerepresentation.interfaces.IReadDirectory"
- factory=".wikipage.Directory"
- permission="zwiki.ViewWikiPage"
- />
-
- <adapter
- for=".interfaces.IWikiPage"
- provides="zope.filerepresentation.interfaces.IWriteDirectory"
- factory=".wikipage.Directory"
- permission="zwiki.CommentWikiPage"
- />
-
- <adapter
- for=".interfaces.IWikiPage"
- provides="zope.filerepresentation.interfaces.IFileFactory"
- factory="zwiki.comment.CommentFileFactory"
- permission="zope.ManageContent"
- />
-
- <!-- Register mail delivery for change mails -->
- <mail:smtpMailer name="wiki-smtp" hostname="localhost" port="25" />
-
- <mail:queuedDelivery
- name="wiki-delivery"
- permission="zope.SendMail"
- queuePath="./mail-queue"
- mailer="wiki-smtp" />
-
- <!-- Register event listener for change mails -->
- <subscriber
- handler=".wikipage.mailer"
- for="zope.app.container.interfaces.IObjectAddedEvent"
- />
- <subscriber
- handler=".wikipage.mailer"
- for="zope.app.container.interfaces.IObjectRemovedEvent"
- />
- <subscriber
- handler=".wikipage.mailer"
- for=".interfaces.IWikiPageEditEvent"
- />
-
-
- <!-- Register various browser related components, including all views -->
- <include package=".browser" />
-
- <!-- Register application with API Doc Tool -->
- <apidoc:rootModule module="zwiki" zcml:condition="have apidoc" />
-
- <!-- Translations -->
- <i18n:registerTranslations directory="locales" />
-
-</configure>
Deleted: zwiki/branches/baijum-experimental-zwiki/diff.py
===================================================================
--- zwiki/branches/baijum-experimental-zwiki/diff.py 2007-03-23 09:29:55 UTC (rev 73483)
+++ zwiki/branches/baijum-experimental-zwiki/diff.py 2007-03-23 11:57:36 UTC (rev 73484)
@@ -1,77 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 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.
-#
-##############################################################################
-"""Browser View Components for WikiPages
-
-$Id$
-"""
-from difflib import SequenceMatcher
-from string import split, join
-
-MAX_OLD_LINES_DISPLAY = 40
-MAX_NEW_LINES_DISPLAY = 40
-
-
-def textdiff(old_text, new_text, verbose=1):
- """
- generate a plain text diff, optimized for human readability,
- between two revisions of this page, numbering back from the latest.
- Alternately, a and/or b texts can be specified.
- """
-
- old = split(old_text, '\n')
- new = split(new_text, '\n')
- cruncher=SequenceMatcher(
- isjunk=lambda x: x in " \\t",
- a=old,
- b=new)
-
- r = []
- for tag, old_lo, old_hi, new_lo, new_hi in cruncher.get_opcodes():
- if tag == 'replace':
- if verbose: r.append('??changed:')
- r = r + _abbreviateDiffLines(old[old_lo:old_hi],'-',
- MAX_OLD_LINES_DISPLAY)
- r = r + _abbreviateDiffLines(new[new_lo:new_hi],'+',
- MAX_NEW_LINES_DISPLAY)
- r.append('')
- elif tag == 'delete':
- if verbose: r.append('--removed:')
- r = r + _abbreviateDiffLines(old[old_lo:old_hi],'-',
- MAX_OLD_LINES_DISPLAY)
- r.append('')
- elif tag == 'insert':
- if verbose: r.append('++added:')
- r = r + _abbreviateDiffLines(new[new_lo:new_hi],'',
- MAX_NEW_LINES_DISPLAY)
- r.append('')
- elif tag == 'equal':
- pass
- else:
- raise ValueError('unknown tag ' + `tag`)
-
- return '\n' + join(r, '\n')
-
-
-def _abbreviateDiffLines(lines, prefix, maxlines=5):
- output = []
- if maxlines and len(lines) > maxlines:
- extra = len(lines) - maxlines
- for i in xrange(maxlines - 1):
- output.append(prefix + lines[i])
- output.append(prefix + "[%d more line%s...]" %
- (extra, ((extra == 1) and '') or 's')) # not working
- else:
- for line in lines:
- output.append(prefix + line)
- return output
Deleted: zwiki/branches/baijum-experimental-zwiki/interfaces.py
===================================================================
--- zwiki/branches/baijum-experimental-zwiki/interfaces.py 2007-03-23 09:29:55 UTC (rev 73483)
+++ zwiki/branches/baijum-experimental-zwiki/interfaces.py 2007-03-23 11:57:36 UTC (rev 73484)
@@ -1,155 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 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.
-#
-##############################################################################
-"""ZWiki Interface Declarations
-
-This module defines the ZWiki relevant interfaces.
-
-$Id$
-"""
-from zope.interface import Interface
-from zope.schema import TextLine, List, SourceText, Choice
-from zope.component.interfaces import IObjectEvent
-
-from zope.app.container.interfaces import IContained
-from zope.app.container.interfaces import IContainer
-from zope.app.container.constraints import contains, containers
-
-from zwiki import ZWikiMessageFactory as _
-
-class IComment(Interface):
- """A simple Wiki Page comment.
-
- This interface specifies only the actual comment. Meta-data will be
- managed via annotations and the Dublin Core as usual.
- """
-
- title = TextLine(
- title=_(u"Title"),
- description=_(u"Comment Title"),
- default=u"",
- required=True)
-
- source = SourceText(
- title=_(u"Source Text"),
- description=_(u"Renderable source text of the comment."),
- default=u"",
- required=True)
-
- type = Choice(
- title=_(u"Source Type"),
- description=_(u"Type of the source text, e.g. structured text"),
- default=u"zope.source.rest",
- required = True,
- vocabulary = "SourceTypes")
-
-
-class IWikiPage(IContainer):
- """A single Wiki Page content object.
-
- The Wiki page is a simple content object that stores the content
- (source) and the source type of the wiki page.
- """
-
- contains(IComment)
-
- source = SourceText(
- title=_(u"Source Text"),
- description=_(u"Renderable source text of the Wiki Page."),
- default=u"",
- required=True)
-
- type = Choice(
- title=_(u"Source Type"),
- description=_(u"Type of the source text, e.g. structured text"),
- default=u"zope.source.rest",
- required = True,
- vocabulary = "SourceTypes")
-
-
-class IWikiPageContained(IContained):
- """Objects that can be contained by Wiki Pages should implement this
- interface."""
-
- containers(IWikiPage)
-
-
-class IWikiPageHierarchy(Interface):
- """This interface supports the virtual hierarchical structure of the Wiki
- Pages."""
-
- parents = List(
- title = _(u"Wiki Page Parents"),
- description = _(u"Parents of a Wiki"),
- value_type = TextLine(title=_(u"Parent Name"),
- description=_(u"Name of the parent wiki page.")),
- required=False)
-
- def reparent(parents):
- """Reset the parents the Wiki page belongs to.
-
- The parents attribute is a list of unicode strings that contain the
- names of the parent wiki pages.
- """
-
- def path():
- """Return the object path of the virtual Wiki Hierarchy.
-
- The return value for this method should be a list of wiki objects
- describing the path.
- """
-
- def findChildren(recursive=True):
- """Returns a list of children for this wiki page.
-
- If the recursive is True, the method recurses into all children
- returning the entire sub-tree of this Wiki Page. Is the recursive
- argument set to False, only the first level of children will be
- returned.
- """
-
-class IWiki(IContainer):
- """A simple container that manages Wikis inside itself."""
-
- contains(IWikiPage)
-
-
-class IWikiContained(IContained):
- """Objects that contain Wikis should implement this interface."""
-
- containers(IWiki)
-
-
-class IWikiPageEditEvent(IObjectEvent):
- """An object event containing the old source in addition
- to the changed object
- """
-
- oldSource = SourceText(
- title=_(u"Previous Source Text"),
- description=_(u"Previous source text of the Wiki Page."),
- default=u"",
- required=True)
-
-class IMailSubscriptions(Interface):
- """This interface allows you to retrieve a list of E-mails for
- mailings. In our context """
-
- def getSubscriptions():
- """Return a list of E-mails."""
-
- def addSubscriptions(emails):
- """Add a bunch of subscriptions, but one would be okay as well."""
-
- def removeSubscriptions(emails):
- """Remove a set of subscriptions."""
Added: zwiki/branches/baijum-experimental-zwiki/setup.py
===================================================================
--- zwiki/branches/baijum-experimental-zwiki/setup.py 2007-03-23 09:29:55 UTC (rev 73483)
+++ zwiki/branches/baijum-experimental-zwiki/setup.py 2007-03-23 11:57:36 UTC (rev 73484)
@@ -0,0 +1,49 @@
+##############################################################################
+#
+# Copyright (c) 2007 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.
+#
+##############################################################################
+"""Setup for zwiki package
+
+$Id: setup.py 73414 2007-03-21 09:21:03Z baijum $
+"""
+
+import os
+from setuptools import setup, find_packages
+
+def read(*rnames):
+ return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
+setup(name = 'zwiki',
+ version = '0.3dev',
+ url = 'http://svn.zope.org/zwiki/trunk',
+ license = 'ZPL 2.1',
+ description = 'A Zope 3 wiki',
+ author = 'Zope Corporation and Contributors',
+ author_email = 'zope3-dev at zope.org',
+ long_description=(
+ read('README.txt')
+ + '\n' +
+ 'Download\n'
+ '**********************\n'
+ ),
+
+ packages = find_packages('src'),
+ package_dir = {'': 'src'},
+
+ tests_require = ['zope.testing'],
+ install_requires = ['setuptools',
+ 'zope.sendmail',
+ 'zope.app'],
+
+ include_package_data = True,
+ zip_safe = False,
+ )
Property changes on: zwiki/branches/baijum-experimental-zwiki/setup.py
___________________________________________________________________
Name: svn:eol-style
+ native
Copied: zwiki/branches/baijum-experimental-zwiki/src/zwiki/CHANGES.txt (from rev 73482, zwiki/branches/baijum-experimental-zwiki/CHANGES.txt)
Copied: zwiki/branches/baijum-experimental-zwiki/src/zwiki/I18N.txt (from rev 73482, zwiki/branches/baijum-experimental-zwiki/I18N.txt)
Copied: zwiki/branches/baijum-experimental-zwiki/src/zwiki/INSTALL.txt (from rev 73482, zwiki/branches/baijum-experimental-zwiki/INSTALL.txt)
Copied: zwiki/branches/baijum-experimental-zwiki/src/zwiki/README.txt (from rev 73482, zwiki/branches/baijum-experimental-zwiki/README.txt)
Copied: zwiki/branches/baijum-experimental-zwiki/src/zwiki/__init__.py (from rev 73482, zwiki/branches/baijum-experimental-zwiki/__init__.py)
Copied: zwiki/branches/baijum-experimental-zwiki/src/zwiki/browser (from rev 73482, zwiki/branches/baijum-experimental-zwiki/browser)
Copied: zwiki/branches/baijum-experimental-zwiki/src/zwiki/comment.py (from rev 73482, zwiki/branches/baijum-experimental-zwiki/comment.py)
Copied: zwiki/branches/baijum-experimental-zwiki/src/zwiki/configure.zcml (from rev 73482, zwiki/branches/baijum-experimental-zwiki/configure.zcml)
Copied: zwiki/branches/baijum-experimental-zwiki/src/zwiki/diff.py (from rev 73482, zwiki/branches/baijum-experimental-zwiki/diff.py)
Copied: zwiki/branches/baijum-experimental-zwiki/src/zwiki/interfaces.py (from rev 73482, zwiki/branches/baijum-experimental-zwiki/interfaces.py)
Copied: zwiki/branches/baijum-experimental-zwiki/src/zwiki/locales (from rev 73482, zwiki/branches/baijum-experimental-zwiki/locales)
Copied: zwiki/branches/baijum-experimental-zwiki/src/zwiki/tests (from rev 73482, zwiki/branches/baijum-experimental-zwiki/tests)
Copied: zwiki/branches/baijum-experimental-zwiki/src/zwiki/traversal.py (from rev 73482, zwiki/branches/baijum-experimental-zwiki/traversal.py)
Copied: zwiki/branches/baijum-experimental-zwiki/src/zwiki/wiki.py (from rev 73482, zwiki/branches/baijum-experimental-zwiki/wiki.py)
Copied: zwiki/branches/baijum-experimental-zwiki/src/zwiki/wikipage.py (from rev 73482, zwiki/branches/baijum-experimental-zwiki/wikipage.py)
Copied: zwiki/branches/baijum-experimental-zwiki/src/zwiki/zwiki-configure.zcml (from rev 73482, zwiki/branches/baijum-experimental-zwiki/zwiki-configure.zcml)
Deleted: zwiki/branches/baijum-experimental-zwiki/traversal.py
===================================================================
--- zwiki/branches/baijum-experimental-zwiki/traversal.py 2007-03-23 09:29:55 UTC (rev 73483)
+++ zwiki/branches/baijum-experimental-zwiki/traversal.py 2007-03-23 11:57:36 UTC (rev 73484)
@@ -1,80 +0,0 @@
-##############################################################################
-# Copyright (c) 2003 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.
-##############################################################################
-"""Specific HTTP
-
-$Id$
-"""
-from zope.interface import implements
-from zope.proxy import removeAllProxies
-from zope.publisher.interfaces import IPublishTraverse, NotFound
-from zope.traversing.interfaces import TraversalError, ITraversable
-from zope.traversing.api import getParent
-from zope.traversing.namespace import UnexpectedParameters
-
-from zope.app import zapi
-
-from zwiki.interfaces import IWikiPage, IWikiPageHierarchy
-
-class WikiPageTraverser:
- implements(IPublishTraverse)
- __used_for__ = IWikiPage
-
- def __init__(self, page, request):
- self.context = page
- self.wiki = getParent(page)
- self.request = request
-
- def publishTraverse(self, request, name):
- page = self.wiki.get(name, None)
-
- # Check that page has self.context as parent
- if page is None or \
- not zapi.getName(self.context) in IWikiPageHierarchy(page).parents:
-
- view = zapi.queryMultiAdapter((self.context, request), name=name)
- if view is not None:
- return view
-
- raise NotFound(self.context, name, request)
-
-
- return removeAllProxies(page)
-
- def browserDefault(self, request):
- c = self.context
- view_name = zapi.getDefaultViewName(c, request)
- view_uri = "@@%s" % view_name
- return c, (view_uri,)
-
-
-_marker = object()
-
-class WikiPageTraversable:
- """Traverses wikipages via wiki itself and getattr.
- """
-
- implements(ITraversable)
- __used_for__ = IWikiPage
-
- def __init__(self, page):
- self._page = page
- self._wiki = getParent(page)
-
-
- def traverse(self, name, furtherPath):
- subobj = self._wiki.get(name, _marker)
- if subobj is _marker:
- subobj = getattr(self._page, name, _marker)
- if subobj is _marker:
- raise TraversalError(self._page, name)
-
- return subobj
Deleted: zwiki/branches/baijum-experimental-zwiki/wiki.py
===================================================================
--- zwiki/branches/baijum-experimental-zwiki/wiki.py 2007-03-23 09:29:55 UTC (rev 73483)
+++ zwiki/branches/baijum-experimental-zwiki/wiki.py 2007-03-23 11:57:36 UTC (rev 73484)
@@ -1,27 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 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.
-#
-##############################################################################
-"""Wiki implementation
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from zope.interface import implements
-from zope.app.folder import Folder
-from zwiki.interfaces import IWiki
-
-class Wiki(Folder):
- __doc__ = IWiki.__doc__
-
- implements(IWiki)
Deleted: zwiki/branches/baijum-experimental-zwiki/wikipage.py
===================================================================
--- zwiki/branches/baijum-experimental-zwiki/wikipage.py 2007-03-23 09:29:55 UTC (rev 73483)
+++ zwiki/branches/baijum-experimental-zwiki/wikipage.py 2007-03-23 11:57:36 UTC (rev 73484)
@@ -1,402 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 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.
-#
-##############################################################################
-"""Wiki implementation
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from email.MIMEText import MIMEText
-from email.Header import Header
-
-from persistent import Persistent
-
-from zope.interface import implements
-from zope.event import notify
-from zope.schema.vocabulary import getVocabularyRegistry
-from zope.annotation.interfaces import IAnnotations
-from zope.component.interfaces import ObjectEvent
-from zope.filerepresentation.interfaces import IReadFile
-from zope.filerepresentation.interfaces import IWriteFile
-from zope.filerepresentation.interfaces import IReadDirectory
-from zope.filerepresentation.interfaces import IWriteDirectory
-from zope.sendmail.interfaces import IMailDelivery
-
-from zope.app import zapi
-from zope.app.container.btree import BTreeContainer
-from zope.app.container.contained import Contained
-from zope.app.container.interfaces import \
- IObjectAddedEvent, IObjectRemovedEvent
-
-from zwiki.interfaces import IWiki, IWikiPage
-from zwiki.interfaces import IWikiContained, IWikiPageContained
-from zwiki.interfaces import IWikiPageHierarchy, IMailSubscriptions
-from zwiki.interfaces import IWikiPageEditEvent
-from zwiki.diff import textdiff
-
-HierarchyKey = 'http://www.zope.org/zwiki#1.0/PageHierarchy/parents'
-SubscriberKey = 'http://www.zope.org/zwiki#1.0/MailSubscriptions/emails'
-
-
-class WikiPage(BTreeContainer):
- """A persistent Wiki Page implementation."""
-
- implements(IWikiPage, IWikiContained)
-
- def __init__(self, source=u''):
- super(WikiPage, self).__init__()
- self._source = source
-
- def _getSource(self):
- return self._source
-
- def _setSource(self, source):
- old_source = self._source
- self._source = source
- notify(WikiPageEditEvent(self, old_source))
-
- # See zwiki.interfaces.IWikiPage
- source = property(_getSource, _setSource)
-
- # See zwiki.interfaces.IWikiPage
- type = u'zope.source.rest'
-
-
-class WikiPageHierarchyAdapter(object):
- __doc__ = IWikiPageHierarchy.__doc__
-
- implements(IWikiPageHierarchy)
- __used_for__ = IWikiPage
-
- def __init__(self, context):
- self.context = context
- self._annotations = IAnnotations(context)
- if not self._annotations.get(HierarchyKey):
- self._annotations[HierarchyKey] = ()
-
- def reparent(self, parents):
- "See zwiki.interfaces.IWikiPageHierarchy"
- self.setParents(parents)
-
- def setParents(self, parents):
- res = []
- for p in parents:
- if p != zapi.name(self.context):
- #don't store myself as a parent
- res.append(p)
- self._annotations[HierarchyKey] = tuple(res)
-
- def getParents(self):
- return self._annotations[HierarchyKey]
-
- parents = property(getParents, setParents)
-
- def path(self):
- "See zwiki.interfaces.IWikiPageHierarchy"
- if not self.getParents():
- return [self.context]
- wiki = zapi.getParent(self.context)
- name = self.getParents()[0]
- hier = IWikiPageHierarchy(wiki[name])
- return hier.path() + [self.context]
-
- def findChildren(self, recursive=True):
- "See zwiki.interfaces.IWikiPageHierarchy"
- wiki = zapi.getParent(self.context)
- contextName = zapi.name(self.context)
- children = []
- for pageName in wiki:
- hier = IWikiPageHierarchy(wiki[pageName])
- if contextName in hier.getParents():
- if recursive:
- subs = hier.findChildren()
- else:
- subs = ()
- children.append((wiki[pageName], subs))
- return tuple(children)
-
-
-
-# Adapters for file-system style access
-
-class Directory(object):
- r"""Adapter to provide a file-system rendition of wiki pages
-
- Usage:
-
- >>> page = WikiPage()
- >>> page.source = 'This is the FrontPage.'
-
- >>> from comment import Comment
- >>> comment = Comment()
- >>> comment.title = u'C1'
- >>> comment.source = u'Comment 1'
- >>> page[u'comment1'] = comment
-
- >>> dir = Directory(page)
- >>> IReadDirectory.providedBy(dir)
- True
- >>> IWriteDirectory.providedBy(dir)
- True
-
- >>> dir.keys()
- [u'comment1', u'content.txt']
- >>> len(dir)
- 2
-
- >>> content = dir.get('content.txt')
- >>> content.__class__ == ContentFile
- True
- >>> comment = dir.get('comment1')
- >>> comment.__class__ == Comment
- True
-
- >>> del dir[u'content.txt']
- >>> dir.keys()
- [u'comment1', u'content.txt']
- >>> del dir[u'comment1']
- >>> dir.keys()
- [u'content.txt']
- """
-
- content_file = u'content.txt'
- implements(IReadDirectory, IWriteDirectory)
- __used_for__ = IWikiPage
-
- def __init__(self, context):
- self.context = context
-
- def keys(self):
- return list(self.context.keys()) + [self.content_file]
-
- def get(self, key, default=None):
- if key == self.content_file:
- return ContentFile(self.context)
- return self.context.get(key, default)
-
- def __iter__(self):
- return iter(self.keys())
-
- def __getitem__(self, key):
- v = self.get(key, self)
- if v is self:
- raise KeyError(key)
- return v
-
- def values(self):
- return map(self.get, self.keys())
-
- def __len__(self):
- return len(self.context)+1
-
- def items(self):
- get = self.get
- return [(key, get(key)) for key in self.keys()]
-
- def __contains__(self, key):
- return self.get(key) is not None
-
- def __setitem__(self, name, object):
- if name == self.content_file:
- pass
- else:
- self.context.__setitem__(name, object)
-
- def __delitem__(self, name):
- if name == self.content_file:
- pass
- else:
- self.context.__delitem__(name)
-
-
-class ContentFile:
- r"""Adapter for letting a Wiki Page look like a regular file.
-
- Usage:
-
- >>> page = WikiPage()
- >>> page.source = 'This is the FrontPage.'
-
- >>> file = ContentFile(page)
- >>> IReadFile.providedBy(file)
- True
- >>> IWriteFile.providedBy(file)
- True
-
- >>> file.read()
- u'Source Type: zope.source.rest\n\nThis is the FrontPage.'
- >>> file.size()
- 53
-
- >>> file.write('Type: zope.source.stx\n\nThis is the FrontPage 2.')
- >>> file.context.type
- u'zope.source.stx'
- >>> file.context.source
- u'This is the FrontPage 2.'
-
- Sometimes the user might not have entered a valid type; let's ignore the
- assignment then.
-
- >>> file.write('Type: zope.source.foo\n\nThis is the FrontPage 3.')
- >>> file.context.type
- u'zope.source.stx'
- >>> file.context.source
- u'This is the FrontPage 3.'
-
- Or the type was ommitted altogether.
-
- >>> file.write('This is the FrontPage 4.')
- >>> file.context.type
- u'zope.source.stx'
- >>> file.context.source
- u'This is the FrontPage 4.'
- """
-
- implements(IReadFile, IWriteFile)
- __used_for__ = IWikiPage
-
- def __init__(self, context):
- self.context = context
-
- def read(self):
- """See zope.filerepresentation.interfaces.IReadFile"""
- text = u'Source Type: %s\n\n' %self.context.type
- text += self.context.source
- return text
-
- def size(self):
- """See zope.filerepresentation.interfaces.IReadFile"""
- return len(self.read())
-
- def write(self, data):
- """See zope.filerepresentation.interfaces.IWriteFile"""
- if data.startswith('Type: '):
- type, data = data.split('\n\n', 1)
- type = type[6:]
- vocab = getVocabularyRegistry().get(self.context, 'SourceTypes')
- if type in [term.value for term in vocab]:
- self.context.type = unicode(type)
-
- self.context.source = unicode(data)
-
-
-# An edit event containing the source before the update
-
-class WikiPageEditEvent(ObjectEvent):
- implements(IWikiPageEditEvent)
-
- oldSource = u''
-
- def __init__(self, object, old_source):
- super(WikiPageEditEvent, self).__init__(object)
- self.oldSource = old_source
-
-# Component to fullfill mail subscriptions
-
-class MailSubscriptions:
- """An adapter for WikiPages to provide an interface for collecting E-mails
- for sending out change notices."""
-
- implements(IMailSubscriptions)
- __used_for__ = IWikiPage, IWiki
-
- def __init__(self, context):
- self.context = context
- self._annotations = IAnnotations(context)
- if not self._annotations.get(SubscriberKey):
- self._annotations[SubscriberKey] = ()
-
- def getSubscriptions(self):
- "See zwiki.interfaces.IMailSubscriptions"
- return self._annotations[SubscriberKey]
-
- def addSubscriptions(self, emails):
- "See zwiki.interfaces.IMailSubscriptions"
- subscribers = list(self._annotations[SubscriberKey])
- for email in emails:
- if email not in subscribers:
- subscribers.append(email.strip())
- self._annotations[SubscriberKey] = tuple(subscribers)
-
- def removeSubscriptions(self, emails):
- "See zwiki.interfaces.IMailSubscriptions"
- subscribers = list(self._annotations[SubscriberKey])
- for email in emails:
- if email in subscribers:
- subscribers.remove(email)
- self._annotations[SubscriberKey] = tuple(subscribers)
-
-
-class WikiMailer(object):
- """Class to handle all outgoing mail."""
-
- fromaddr = "wiki at zope3.org"
- encoding = "utf-8"
-
- def __call__(self, event):
- if IWikiPage.providedBy(event.object):
- if IObjectAddedEvent.providedBy(event):
- self.handleAdded(event.object)
-
- elif IWikiPageEditEvent.providedBy(event):
- self.handleModified(event)
-
- elif IObjectRemovedEvent.providedBy(event):
- self.handleRemoved(event.object)
-
- def handleAdded(self, object):
- subject = 'Added: ' + zapi.name(object)
- emails = self.getAllSubscribers(object)
- body = object.source
- self.mail(emails, subject, body)
-
- def handleModified(self, event):
- object = event.object
- if zapi.name(object) is not None:
- subject = 'Modified: ' + zapi.name(object)
- emails = self.getAllSubscribers(object)
- body = textdiff(event.oldSource, object.source)
- self.mail(emails, subject, body)
-
- def handleRemoved(self, object):
- subject = 'Removed: ' + zapi.name(object)
- emails = self.getAllSubscribers(object)
- body = subject
- self.mail(emails, subject, body)
-
- def getAllSubscribers(self, object):
- """Retrieves all email subscribers by looking into the local Wiki Page
- and into the Wiki for the global subscriptions."""
- emails = tuple(IMailSubscriptions(object).getSubscriptions())
- emails += tuple(IMailSubscriptions(zapi.getParent(object)
- ).getSubscriptions())
- return emails
-
- def mail(self, emails, subject, body):
- """Mail out the Wiki change message."""
- if emails:
- msg = self._getMessage(subject, body)
- mail_delivery = zapi.getUtility(IMailDelivery, 'wiki-delivery')
- mail_delivery.send(self.fromaddr, emails, msg)
-
- def _getMessage(self, subject, body):
- message = MIMEText(body.encode(self.encoding), "plain", self.encoding)
- message["Subject"] = Header(
- subject.encode(self.encoding), self.encoding)
- message["From"] = self.fromaddr
- message["To"] = self.fromaddr
- return message.as_string()
-
-# Create a global mailer object.
-mailer = WikiMailer()
Deleted: zwiki/branches/baijum-experimental-zwiki/zwiki-configure.zcml
===================================================================
--- zwiki/branches/baijum-experimental-zwiki/zwiki-configure.zcml 2007-03-23 09:29:55 UTC (rev 73483)
+++ zwiki/branches/baijum-experimental-zwiki/zwiki-configure.zcml 2007-03-23 11:57:36 UTC (rev 73484)
@@ -1 +0,0 @@
-<include package="zwiki" />
More information about the Checkins
mailing list