[Checkins] SVN: z3c.weblog/trunk/ initial import

Michael Bernstein michael at fandomhome.com
Wed Sep 26 18:25:21 EDT 2007


Log message for revision 80160:
  initial import
  

Changed:
  A   z3c.weblog/trunk/README.txt
  A   z3c.weblog/trunk/bootstrap.py
  A   z3c.weblog/trunk/buildout.cfg
  A   z3c.weblog/trunk/setup.py
  A   z3c.weblog/trunk/src/
  A   z3c.weblog/trunk/src/z3c/
  A   z3c.weblog/trunk/src/z3c/__init__.py
  A   z3c.weblog/trunk/src/z3c/weblog/
  A   z3c.weblog/trunk/src/z3c/weblog/README.txt
  A   z3c.weblog/trunk/src/z3c/weblog/__init__.py
  A   z3c.weblog/trunk/src/z3c/weblog/browser/
  A   z3c.weblog/trunk/src/z3c/weblog/browser/__init__.py
  A   z3c.weblog/trunk/src/z3c/weblog/browser/atomfeed.pt
  A   z3c.weblog/trunk/src/z3c/weblog/browser/configure.zcml
  A   z3c.weblog/trunk/src/z3c/weblog/browser/entry.pt
  A   z3c.weblog/trunk/src/z3c/weblog/browser/entry.py
  A   z3c.weblog/trunk/src/z3c/weblog/browser/skin/
  A   z3c.weblog/trunk/src/z3c/weblog/browser/skin/__init__.py
  A   z3c.weblog/trunk/src/z3c/weblog/browser/skin/changeskin.py
  A   z3c.weblog/trunk/src/z3c/weblog/browser/skin/changeskin.txt
  A   z3c.weblog/trunk/src/z3c/weblog/browser/skin/configure.zcml
  A   z3c.weblog/trunk/src/z3c/weblog/browser/skin/template.pt
  A   z3c.weblog/trunk/src/z3c/weblog/browser/weblog.pt
  A   z3c.weblog/trunk/src/z3c/weblog/browser/weblog.py
  A   z3c.weblog/trunk/src/z3c/weblog/configure.zcml
  A   z3c.weblog/trunk/src/z3c/weblog/docs/
  A   z3c.weblog/trunk/src/z3c/weblog/docs/atomanddublincore.txt
  A   z3c.weblog/trunk/src/z3c/weblog/entry.py
  A   z3c.weblog/trunk/src/z3c/weblog/interfaces.py
  A   z3c.weblog/trunk/src/z3c/weblog/tests.py
  A   z3c.weblog/trunk/src/z3c/weblog/weblog.py

-=-
Added: z3c.weblog/trunk/README.txt
===================================================================
--- z3c.weblog/trunk/README.txt	                        (rev 0)
+++ z3c.weblog/trunk/README.txt	2007-09-26 22:25:20 UTC (rev 80160)
@@ -0,0 +1 @@
+This package provides a weblog implementation for Zope 3.

Added: z3c.weblog/trunk/bootstrap.py
===================================================================
--- z3c.weblog/trunk/bootstrap.py	                        (rev 0)
+++ z3c.weblog/trunk/bootstrap.py	2007-09-26 22:25:20 UTC (rev 80160)
@@ -0,0 +1,52 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""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 75887 2007-05-22 16:59:21Z srichter $
+"""
+
+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)

Added: z3c.weblog/trunk/buildout.cfg
===================================================================
--- z3c.weblog/trunk/buildout.cfg	                        (rev 0)
+++ z3c.weblog/trunk/buildout.cfg	2007-09-26 22:25:20 UTC (rev 80160)
@@ -0,0 +1,7 @@
+[buildout]
+develop = .
+parts = test
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = z3c.weblog [test]

Added: z3c.weblog/trunk/setup.py
===================================================================
--- z3c.weblog/trunk/setup.py	                        (rev 0)
+++ z3c.weblog/trunk/setup.py	2007-09-26 22:25:20 UTC (rev 80160)
@@ -0,0 +1,68 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation 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
+
+"""
+import os
+from setuptools import setup, find_packages
+
+def read(*rnames):
+    return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
+setup (
+    name='z3c.weblog',
+    version='0.1dev',
+    author = "Michael R. Bernstein",
+    author_email = "michael at fandomhome.com",
+    description = "A basic weblog implementation for Zope 3.",
+    long_description=(
+        read('README.txt')
+        + '\n' +
+        'Detailed Documentation\n'
+        '**********************\n'
+        + '\n' +
+        read('src', 'z3c', 'weblog', 'README.txt')
+        ),
+    license = "??",
+    keywords = "zope3",
+    classifiers = [
+        'Environment :: Web Environment',
+        'Intended Audience :: Developers',
+        'Programming Language :: Python',
+        'Natural Language :: English',
+        'Operating System :: OS Independent',
+        'Topic :: Internet :: WWW/HTTP',
+        'Framework :: Zope3'],
+    packages = find_packages('src'),
+    include_package_data = True,
+    package_dir = {'':'src'},
+    namespace_packages = ['z3c'],
+    extras_require = dict(
+        test = [
+            'zope.testing',
+            'zope.app.container [test]',
+            ],
+        ),
+    install_requires = [
+        'setuptools',
+        'zope.interface',
+        'ZODB3',
+        'zope.schema',
+        'zope.app.container',
+        'zope.app.content',
+        'zope.dublincore',
+        ],
+    dependency_links = ['http://download.zope.org/distribution'],
+    zip_safe = False,
+    )

Added: z3c.weblog/trunk/src/z3c/__init__.py
===================================================================
--- z3c.weblog/trunk/src/z3c/__init__.py	                        (rev 0)
+++ z3c.weblog/trunk/src/z3c/__init__.py	2007-09-26 22:25:20 UTC (rev 80160)
@@ -0,0 +1,8 @@
+try:
+    # Declare this a namespace package if pkg_resources is available.
+    import pkg_resources
+    pkg_resources.declare_namespace('jsa')
+except ImportError:
+    pass
+
+

Added: z3c.weblog/trunk/src/z3c/weblog/README.txt
===================================================================

Added: z3c.weblog/trunk/src/z3c/weblog/__init__.py
===================================================================

Added: z3c.weblog/trunk/src/z3c/weblog/browser/__init__.py
===================================================================

Added: z3c.weblog/trunk/src/z3c/weblog/browser/atomfeed.pt
===================================================================
--- z3c.weblog/trunk/src/z3c/weblog/browser/atomfeed.pt	                        (rev 0)
+++ z3c.weblog/trunk/src/z3c/weblog/browser/atomfeed.pt	2007-09-26 22:25:20 UTC (rev 80160)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feed
+    xmlns="http://purl.org/atom/ns#draft-ietf-atompub-format-06"
+    xmlns:tal="http://xml.zope.org/namespaces/tal">
+
+ <title tal:content="view/title" type="text/plain" mode="escaped">Example Feed</title>
+ <tagline tal:content="view/description" type="text/html" mode="escaped">Tagline</tagline>
+ <link tal:attributes="href context/@@absolute_url" href="http://example.org/"/>
+ <updated tal:content="view/modified">2003-12-13T18:30:02Z</updated>
+ <author>
+  <name tal:content="view/author">John Doe</name>
+ </author>
+
+ <entry tal:repeat="entry view/getEntryData">
+  <title tal:content="entry/title" type="text/plain" mode="escaped">Atom-Powered Robots Run Amok</title>
+  <link tal:attributes="href entry/link" href="http://example.org/2003/12/13/atom03"/>
+  <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
+  <summary tal:content="entry/description" type="text/html" mode="escaped">Description</summary>
+  <updated tal:content="entry/modified">2003-12-13T18:30:02Z</updated>
+ </entry>
+</feed>

Added: z3c.weblog/trunk/src/z3c/weblog/browser/configure.zcml
===================================================================
--- z3c.weblog/trunk/src/z3c/weblog/browser/configure.zcml	                        (rev 0)
+++ z3c.weblog/trunk/src/z3c/weblog/browser/configure.zcml	2007-09-26 22:25:20 UTC (rev 80160)
@@ -0,0 +1,110 @@
+<configure
+    xmlns="http://namespaces.zope.org/browser"
+    xmlns:zope="http://namespaces.zope.org/zope">
+  <include package=".skin" />
+  <addform
+      label="Add Weblog"
+      name="AddWeblog.html"
+      schema="z3c.weblog.interfaces.IDCWeblog"
+      content_factory="z3c.weblog.weblog.Weblog"
+      fields="title description"
+      permission="zope.ManageContent"
+      />
+
+  <addMenuItem
+      class="z3c.weblog.weblog.Weblog"
+      title="Weblog"
+      description="A Weblog"
+      permission="zope.ManageContent"
+      view="AddWeblog.html"
+      />
+
+  <editform
+      schema="z3c.weblog.interfaces.IDCWeblog"
+      for="z3c.weblog.interfaces.IDCWeblog"
+      label="Change Weblog"
+      name="edit.html"
+      permission="zope.ManageContent"
+      menu="zmi_views" title="Edit"
+      />
+
+  <page 
+      name="view.html"
+      for="z3c.weblog.interfaces.IWeblog"
+      class=".weblog.WeblogView"
+      template="weblog.pt"
+      permission="zope.View"
+      menu="zmi_views"
+      title="View"
+      />
+
+  <containerViews
+      for="z3c.weblog.interfaces.IWeblog"
+      index="zope.View"
+      contents="zope.ManageContent"
+      add="zope.ManageContent"
+      />
+
+ <page
+     name="atom.xml"
+     for="z3c.weblog.interfaces.IWeblog"
+     class=".weblog.WeblogView"
+     template="atomfeed.pt"
+     permission="zope.Public"
+     menu="zmi_views"
+     title="Atom Syndication"
+     />
+
+  <defaultView
+      for="z3c.weblog.interfaces.IWeblog"
+      name="view.html"
+      />
+
+  <zope:subscriber
+      for="zope.app.publication.interfaces.IBeforeTraverseEvent"
+      factory=".skin.changeskin.objectSkin"
+      />
+      
+  <addform
+      label="Add Entry"
+      name="AddEntry.html"
+      schema="z3c.weblog.interfaces.IDCEntry"
+      content_factory="z3c.weblog.entry.Entry"
+      fields="title description content"
+      permission="zope.ManageContent"
+      />
+
+  <addMenuItem
+      class="z3c.weblog.entry.Entry"
+      title="Entry"
+      description="A Entry"
+      permission="zope.ManageContent"
+      view="AddEntry.html"
+      />
+
+  <page
+      name="details.html"
+      for="z3c.weblog.interfaces.IEntry"
+      class=".entry.EntryDetails"
+      template="entry.pt"
+      permission="zope.Public"
+      menu="zmi_views"
+      title="Preview"
+      />
+
+  <editform
+      schema="z3c.weblog.interfaces.IDCEntry"
+      for="z3c.weblog.interfaces.IEntry"
+      label="Change Entry"
+      fields="title description content"
+      name="edit.html"
+      permission="zope.ManageContent"
+      menu="zmi_views" title="Edit"
+      />
+
+  <defaultView
+      for="z3c.weblog.interfaces.IEntry"
+      name="details.html"
+      />
+
+</configure>

Added: z3c.weblog/trunk/src/z3c/weblog/browser/entry.pt
===================================================================
--- z3c.weblog/trunk/src/z3c/weblog/browser/entry.pt	                        (rev 0)
+++ z3c.weblog/trunk/src/z3c/weblog/browser/entry.pt	2007-09-26 22:25:20 UTC (rev 80160)
@@ -0,0 +1,15 @@
+<html metal:use-macro="views/standard_macros/view">
+  <body>
+    <div metal:fill-slot="body">
+
+	<h1 tal:content="structure view/title">Title</h1>
+        <h2>By <tal:span tal:content="view/author">Author</tal:span></h2>
+        <tal:span tal:content="view/modified">2005-03-20</tal:span>
+        <blockquote tal:content="structure view/description">Description</blockquote>
+        <div class="row">
+            <div tal:content="structure context/content"/>
+        </div>
+
+    </div>
+  </body>
+</html>

Added: z3c.weblog/trunk/src/z3c/weblog/browser/entry.py
===================================================================
--- z3c.weblog/trunk/src/z3c/weblog/browser/entry.py	                        (rev 0)
+++ z3c.weblog/trunk/src/z3c/weblog/browser/entry.py	2007-09-26 22:25:20 UTC (rev 80160)
@@ -0,0 +1,25 @@
+from zope.app import zapi
+from zope.dublincore.interfaces import ICMFDublinCore
+
+class EntryDetails:
+
+    def author(self):
+        """Get user who last modified the Message."""
+        creators = ICMFDublinCore(self.context).creators
+        if not creators:
+            return 'unknown'
+        return creators[0]
+
+    def description(self):
+        """Get description of Entry"""
+        return ICMFDublinCore(self.context).description
+
+    def modified(self):
+        """Get last modification date."""
+        date = ICMFDublinCore(self.context).modified or \
+               ICMFDublinCore(self.context).created or ''
+        return date.strftime('%FT%TZ')
+
+    def title(self):
+        """Get title of Entry"""
+        return ICMFDublinCore(self.context).title

Added: z3c.weblog/trunk/src/z3c/weblog/browser/skin/__init__.py
===================================================================

Added: z3c.weblog/trunk/src/z3c/weblog/browser/skin/changeskin.py
===================================================================
--- z3c.weblog/trunk/src/z3c/weblog/browser/skin/changeskin.py	                        (rev 0)
+++ z3c.weblog/trunk/src/z3c/weblog/browser/skin/changeskin.py	2007-09-26 22:25:20 UTC (rev 80160)
@@ -0,0 +1,5 @@
+from z3c.weblog.interfaces import IWeblog
+
+def objectSkin(event):
+    if IWeblog.providedBy(event.object) and event.request.principal.id == 'zope.anybody':
+        event.request.setPresentationSkin('weblog')

Added: z3c.weblog/trunk/src/z3c/weblog/browser/skin/changeskin.txt
===================================================================
--- z3c.weblog/trunk/src/z3c/weblog/browser/skin/changeskin.txt	                        (rev 0)
+++ z3c.weblog/trunk/src/z3c/weblog/browser/skin/changeskin.txt	2007-09-26 22:25:20 UTC (rev 80160)
@@ -0,0 +1,37 @@
+Change Skin
+==========
+
+We'll put a test here later, meanwhile here is an edited session that Jim walked us through.
+
+>>> from zope.publisher.browser import TestRequest
+>>> r = TestRequest
+>>> r = TestRequest()
+>>> from zope.interface import *
+>>> list(providedBy(r))
+[<InterfaceClass zope.publisher.interfaces.browser.IBrowserRequest>,
+<InterfaceClass
+zope.publisher.interfaces.browser.IBrowserApplicationRequest>,
+<InterfaceClass zope.publisher.interfaces.http.IHTTPCredentials>,
+<InterfaceClass zope.publisher.interfaces.http.IHTTPRequest>,
+<InterfaceClass zope.publisher.interfaces.http.IHTTPApplicationRequest>,
+<InterfaceClass zope.publisher.interfaces.IRequest>]
+>>> list(directlyProvidedBy(r))
+[]
+>>> class i1(Interface):
+...     pass
+...
+>>> directlyProvides(r, i1)
+>>> list(directlyProvidedBy(r))
+[<InterfaceClass __main__.i1>]
+>>> class i2(Interface):
+...     pass
+...
+>>> directlyProvides(r, i2)
+>>> list(directlyProvidedBy(r))
+[<InterfaceClass __main__.i2>]
+>>> directlyProvides(r, i2, i1)
+>>> list(directlyProvidedBy(r))
+[<InterfaceClass __main__.i2>, <InterfaceClass __main__.i1>]
+>>> r.getPresentationSkin()
+'default'
+>>>

Added: z3c.weblog/trunk/src/z3c/weblog/browser/skin/configure.zcml
===================================================================
--- z3c.weblog/trunk/src/z3c/weblog/browser/skin/configure.zcml	                        (rev 0)
+++ z3c.weblog/trunk/src/z3c/weblog/browser/skin/configure.zcml	2007-09-26 22:25:20 UTC (rev 80160)
@@ -0,0 +1,14 @@
+<configure 
+    xmlns="http://namespaces.zope.org/browser">
+ <layer name="weblog" />
+
+ <skin name="weblog" layers="weblog rotterdam default" />
+ 
+ <page
+    for="*"
+    name="skin_macros"
+    permission="zope.View"
+    layer="weblog"
+    template="template.pt" />
+
+</configure>

Added: z3c.weblog/trunk/src/z3c/weblog/browser/skin/template.pt
===================================================================
--- z3c.weblog/trunk/src/z3c/weblog/browser/skin/template.pt	                        (rev 0)
+++ z3c.weblog/trunk/src/z3c/weblog/browser/skin/template.pt	2007-09-26 22:25:20 UTC (rev 80160)
@@ -0,0 +1,73 @@
+<metal:block define-macro="page">
+ <metal:block define-slot="doctype">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+ </metal:block>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta name="generator" content="http://www.inknoise.com/experimental/layoutomatic.php" />	<style type="text/css">
+		#container {
+			width: 760px;
+			\width: 780px;
+			w\idth: 760px;
+			border: 1px solid gray;
+			margin: 10px;
+			margin-left: auto;
+			margin-right: auto;
+			padding: 10px;
+		}
+
+		#banner {
+			padding: 5px;
+			margin-bottom: 5px;
+			background-color: rgb(213, 219, 225);
+		}
+
+		#content {
+			padding: 5px;
+			margin-right: 215px;
+			background-color: gray;
+		}
+
+		#sidebar-a {
+			float: right;
+			width: 200px;
+			\width: 210px;
+			w\idth: 200px;
+			margin: 0;
+			margin-left: 5px;
+			padding: 5px;
+			background-color: rgb(235, 235, 235);
+		}
+
+		#footer {
+			clear: both;
+			padding: 5px;
+			margin-top: 5px;
+			
+			background-color: rgb(213, 219, 225);
+		}
+	</style>
+ <title metal:define-slot="title" >Weblog Title</title>
+</head>
+<body>
+	<div id="container">
+		<div id="banner">
+                 <h1 tal:content="view/title">Title</h1>
+                </div>
+
+		<div id="sidebar-a"
+                     metal:define-slot="sidebar">sidebar goes here</div>
+
+<div id="content"
+     metal:define-slot="body">
+        <div class="row" tal:repeat="entry view/getEntryData">
+         <h2><a href="" tal:attributes="href entry/link" tal:content="entry/title">Entry Title</a></h2>
+        <tal:span tal:content="entry/modified">2005-03-20</tal:span>
+        <blockquote tal:content="entry/description">Description</blockquote>
+        </div>
+</div>
+		<div id="footer">&nbsp;</div>
+	</div>
+</body>
+</html>
+</metal:block>

Added: z3c.weblog/trunk/src/z3c/weblog/browser/weblog.pt
===================================================================
--- z3c.weblog/trunk/src/z3c/weblog/browser/weblog.pt	                        (rev 0)
+++ z3c.weblog/trunk/src/z3c/weblog/browser/weblog.pt	2007-09-26 22:25:20 UTC (rev 80160)
@@ -0,0 +1,14 @@
+<html metal:use-macro="views/standard_macros/view">
+  <body>
+    <div metal:fill-slot="body">
+
+	<h1 tal:content="structure view/title">Title</h1>
+        <div class="row" tal:repeat="entry view/getEntryData">
+         <h2><a href="" tal:attributes="href entry/link" tal:content="structure entry/title">Entry Title</a></h2>
+        <tal:span tal:content="entry/modified">2005-03-20</tal:span>
+        <blockquote tal:content="structure entry/description">Description</blockquote>
+        </div>
+
+    </div>
+  </body>
+</html>

Added: z3c.weblog/trunk/src/z3c/weblog/browser/weblog.py
===================================================================
--- z3c.weblog/trunk/src/z3c/weblog/browser/weblog.py	                        (rev 0)
+++ z3c.weblog/trunk/src/z3c/weblog/browser/weblog.py	2007-09-26 22:25:20 UTC (rev 80160)
@@ -0,0 +1,43 @@
+from zope.app import zapi
+from zope.dublincore.interfaces import ICMFDublinCore
+from zope.app.container.interfaces import IContentContainer
+
+class WeblogView:
+
+    def description(self):
+        """Get description of Entry"""
+        return ICMFDublinCore(self.context).description
+
+    def modified(self):
+        """Get last modification date."""
+        date = ICMFDublinCore(self.context).modified or \
+               ICMFDublinCore(self.context).created or ''
+        return date.strftime('%FT%TZ')
+
+    def author(self):
+        """Get the Author of the weblog"""
+        # What we actually want is the author, but for now we'll use the creator
+        creators = ICMFDublinCore(self.context).creators
+        if not creators:
+            return 'unknown'
+        return creators[0]
+
+    def title(self):
+        """Get title of Entry"""
+        return ICMFDublinCore(self.context).title
+
+    def getEntryData(self):
+        """Get the contained object's data"""
+        entries = []
+        for entry in IContentContainer(self.context).values():
+            date = ICMFDublinCore(entry).modified or \
+                   ICMFDublinCore(entry).created or ''
+            d = dict(
+                title = ICMFDublinCore(entry).title,
+                modified = date.strftime('%FT%TZ'),
+                link = zapi.absoluteURL(entry, self.request),
+                description = ICMFDublinCore(entry).description,
+                )
+            entries.append(d)
+        return entries
+

Added: z3c.weblog/trunk/src/z3c/weblog/configure.zcml
===================================================================
--- z3c.weblog/trunk/src/z3c/weblog/configure.zcml	                        (rev 0)
+++ z3c.weblog/trunk/src/z3c/weblog/configure.zcml	2007-09-26 22:25:20 UTC (rev 80160)
@@ -0,0 +1,68 @@
+<configure
+    xmlns="http://namespaces.zope.org/zope"
+    i18n_domain="z3c.weblog">
+
+  <include package=".browser" />
+  <interface
+      interface=".interfaces.IWeblog"
+      type="zope.app.content.interfaces.IContentType"
+      />
+
+  <content class=".weblog.Weblog">
+    <implements
+        interface="zope.app.annotation.interfaces.IAttributeAnnotatable
+	zope.app.container.interfaces.IContentContainer"
+        />
+    <factory
+        id="weblog.Weblog"
+        description="Weblog"
+        />
+    <require
+        permission="zope.View"
+        interface="zope.app.container.interfaces.IReadContainer"
+        />
+    <require
+        permission="zope.ManageContent"
+        interface="zope.app.container.interfaces.IWriteContainer"
+        />
+  </content>
+
+  <adapter
+      factory=".weblog.DCWeblog"
+      provides=".interfaces.IDCWeblog"
+      for=".interfaces.IWeblog"
+      />
+
+  <class class=".weblog.DCWeblog">
+    <require
+        permission="zope.ManageContent"
+        set_schema=".interfaces.IDCWeblog"
+        />
+  </class>
+
+  <interface
+      interface=".interfaces.IEntry"
+      type="zope.app.content.interfaces.IContentType"
+      />
+
+  <content class=".entry.Entry">
+    <implements
+        interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
+        />
+    <require
+        permission="zope.Public"
+        interface=".interfaces.IEntry"
+        />
+    <require
+        permission="zope.ManageContent"
+        set_schema=".interfaces.IEntry"
+        />
+  </content>
+
+  <adapter
+      factory=".entry.DCEntry"
+      provides=".interfaces.IDCEntry"
+      for=".interfaces.IEntry"
+      />
+
+</configure>

Added: z3c.weblog/trunk/src/z3c/weblog/docs/atomanddublincore.txt
===================================================================
--- z3c.weblog/trunk/src/z3c/weblog/docs/atomanddublincore.txt	                        (rev 0)
+++ z3c.weblog/trunk/src/z3c/weblog/docs/atomanddublincore.txt	2007-09-26 22:25:20 UTC (rev 80160)
@@ -0,0 +1,22 @@
+this is a quick overview of the elements defined by the Atom format, and how
+we think they map to Zope3, particularly Zope3's implementation of Dublin Core.
+
+Atom Element | Entry | Feed | Zope DC     | weblog imlementation
+================================================================
+content      |  X    |      |             |     X
+author       |  X    |  X   | creator     |     
+category     |  X    |  X   | subject?    |
+contributor  |  X    |  X   | contributor |
+copyright    |  X    |  X   | rights?     |
+generator    |       |  X   |             |     X
+icon         |       |  X   |             |     X
+id           |  X    |  X   | identifier? |
+image        |       |  X   |             |     X
+link         |  X    |  X   | relation?   | absolute URL?
+published    |  X    |      | date?       | ICMF.created
+source-feed  |  X    |      | source?     | The source feed element has same
+             |       |      |             | sub-elements as feed (except entry).
+subtitle     |       |  X   | description |
+summary      |  X    |      | description |
+title        |  X    |  X   | title       |
+updated      |  X    |  X   | date?       | ICMF.modified

Added: z3c.weblog/trunk/src/z3c/weblog/entry.py
===================================================================
--- z3c.weblog/trunk/src/z3c/weblog/entry.py	                        (rev 0)
+++ z3c.weblog/trunk/src/z3c/weblog/entry.py	2007-09-26 22:25:20 UTC (rev 80160)
@@ -0,0 +1,60 @@
+from zope.interface import implements
+from zope.dublincore.interfaces import IZopeDublinCore
+from zope.app.container.contained import Contained
+from persistent import Persistent
+from z3c.weblog.interfaces import IEntry, IEntryContained, IDCEntry
+
+class Entry(Persistent, Contained):
+    """A Weblog Entry
+
+    >>> e = Entry()
+    >>>
+    """
+
+    implements(IEntry, IEntryContained)
+
+    # See weblog.interfaces.IEntry
+    content = None
+
+
+class DCEntry(object):
+    """Weblog Entry with Dublin Core support
+    
+    >>> e = DCEntry(Entry())
+    >>>
+    """
+    
+    implements(IDCEntry)
+    __used_for__ = IEntry
+
+    def __init__(self, entry):
+        self._entry = entry
+
+    def getTitle(self):
+        return IZopeDublinCore(self._entry).title
+    
+    def setTitle(self, title):
+        IZopeDublinCore(self._entry).title = title
+
+    title = property(getTitle, setTitle, doc="Weblog Entry title")
+
+    def getDescription(self):
+        return IZopeDublinCore(self._entry).description
+    
+    def setDescription(self, description):
+        IZopeDublinCore(self._entry).description = description
+
+    description = property(getDescription, setDescription,
+                           doc="Description of the Weblog Entry")
+    
+    def getContent(self):
+        return self._entry.content
+    
+    def setContent(self, content):
+        self._entry.content = content
+
+    content = property(getContent, setContent,
+                       doc="Content of the Weblog Entry")
+    
+
+

Added: z3c.weblog/trunk/src/z3c/weblog/interfaces.py
===================================================================
--- z3c.weblog/trunk/src/z3c/weblog/interfaces.py	                        (rev 0)
+++ z3c.weblog/trunk/src/z3c/weblog/interfaces.py	2007-09-26 22:25:20 UTC (rev 80160)
@@ -0,0 +1,58 @@
+from zope.interface import Interface
+from zope.schema import Text, TextLine, Field
+
+from zope.app.container.constraints import ContainerTypesConstraint
+from zope.app.container.constraints import ItemTypePrecondition
+from zope.app.container.interfaces import IContained, IContainer
+from zope.app.content.interfaces import IContentType
+from zope.dublincore.interfaces import IDCDescriptiveProperties
+from persistent.interfaces import IPersistent
+from zope.app.file.interfaces import IFile
+
+class IEntry(IPersistent):
+
+    """A Entry for a Weblog"""
+
+    id = TextLine(
+        title = u"Unique Identifier",
+        description = u"A unique identifier that never changes",
+        readonly = True,
+        required = True,
+    )
+
+    content = Text(
+        title = u"Entry Content",
+        description = u"Content for the Entry",
+        default = u"",
+        required = True,
+        )
+
+
+class IWeblog(IContainer):
+
+    """A Weblog"""
+
+    def __setitem__(name, object):
+        """Add an Entry"""
+
+    __setitem__.precondition = ItemTypePrecondition(IEntry)
+
+
+class IEntryContained(IContained):
+
+    """Interface that specifies what can contain Entrys"""
+
+    __parent__ = Field(
+        constraint=ContainerTypesConstraint(IWeblog, IEntry),
+        )
+    
+
+class IDCEntry(IEntry, IDCDescriptiveProperties):
+
+    """Entry with support for Dublin Core"""
+
+
+class IDCWeblog(IWeblog, IDCDescriptiveProperties):
+
+    """Weblog with DC"""
+

Added: z3c.weblog/trunk/src/z3c/weblog/tests.py
===================================================================
--- z3c.weblog/trunk/src/z3c/weblog/tests.py	                        (rev 0)
+++ z3c.weblog/trunk/src/z3c/weblog/tests.py	2007-09-26 22:25:20 UTC (rev 80160)
@@ -0,0 +1,32 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Base Components test setup
+
+$Id: tests.py 70205 2006-09-16 12:43:33Z srichter $
+"""
+__docformat__ = "reStructuredText"
+import doctest
+import unittest
+from zope.testing.doctestunit import DocFileSuite, pprint
+
+def test_suite():
+    return unittest.TestSuite((
+        DocFileSuite('README.txt',
+                     optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
+                     globs={'pprint': pprint}
+                     ),
+        ))
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')

Added: z3c.weblog/trunk/src/z3c/weblog/weblog.py
===================================================================
--- z3c.weblog/trunk/src/z3c/weblog/weblog.py	                        (rev 0)
+++ z3c.weblog/trunk/src/z3c/weblog/weblog.py	2007-09-26 22:25:20 UTC (rev 80160)
@@ -0,0 +1,49 @@
+from zope.interface import implements
+from zope.dublincore.interfaces import IZopeDublinCore
+from zope.app.container.btree import BTreeContainer
+
+from z3c.weblog.interfaces import IWeblog, IDCWeblog, IEntry, IDCEntry
+
+class Weblog(BTreeContainer):
+    """A Weblog using BTreeContainers
+    
+    >>> from zope.interface.verify import verifyClass
+    >>> verifyClass(IWeblog, Weblog)
+    True
+
+    >>> weblog = Weblog()
+    >>>
+    """
+
+    implements(IWeblog)
+    
+
+class DCWeblog(object):
+
+    implements(IDCWeblog)
+    __used_for__ = IWeblog
+
+    def __init__(self, weblog):
+        self._weblog = weblog
+
+    def getTitle(self):
+        """getTitle"""
+        return IZopeDublinCore(self._weblog).title
+
+    def setTitle(self, title):
+        """setTitle"""
+        IZopeDublinCore(self._weblog).title = title
+
+    title = property(getTitle, setTitle, doc="The Weblog's title")
+
+    def getDescription(self):
+        """getDesc"""
+        return IZopeDublinCore(self._weblog).description
+    
+    def setDescription(self, description):
+        """getDesc"""
+        IZopeDublinCore(self._weblog).description = description
+
+    description = property(getDescription, setDescription,
+                           doc="Description of the Weblog")
+    



More information about the Checkins mailing list