[zopeorg-checkins] CVS: Products/ZDBase - README.txt:1.1 ZDiscussions.py:1.1 __init__.py:1.1

Sidnei da Silva sidnei at x3ng.com.br
Fri May 30 11:17:58 EDT 2003


Update of /cvs-zopeorg/Products/ZDBase
In directory cvs.zope.org:/tmp/cvs-serv19195/ZDBase

Added Files:
	README.txt ZDiscussions.py __init__.py 
Log Message:
Adding products needed for migration of NZO

=== Added File Products/ZDBase/README.txt ===
Z Discussions Base Classes

 Contents

  About this release

  What is ZDBase?

  License and support

 About this release

  This is the first public release of ZDBase.  It is very much beta.
  It is likely to work, but it may not work in the way you'd like it
  to.  Please feel free to submit bug reports and feature requests to
  Mike Pelleter at mike at digicool.com.

 What is ZDBase?

  Unlike most Products, this one doesn't add anything to your Add
  menu.  ZDBase contains two classes which are the base classes for
  the ZDConfera and ZDiscussions discussion objects.  To get any
  use out of ZDBase, you will need to install one of those (and vice
  versa).

  ZDBase provides these services:

   o Body searches

   o Interesting searches such as new since last visit, replies to an 
     author, most popular posts, etc.

   o Thread management

   o RSS channels (erm, next release.)

 License and support

  Z Discussions and ZDConfera have been released under the Zope Public 
  License (ZPL).  Please see http://www.zope.org/Resources/License.

  This release is officially unsupported. It is presently under the
  care of Mike Pelletier ( mike at digicool.com ) who will be happy to
  offer unofficial support.


=== Added File Products/ZDBase/ZDiscussions.py ===
##############################################################################
# 
# Zope Public License (ZPL) Version 1.0
# -------------------------------------
# 
# Copyright (c) Digital Creations.  All rights reserved.
# 
# This license has been certified as Open Source(tm).
# 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# 
# 1. Redistributions in source code must retain the above copyright
#    notice, this list of conditions, and the following disclaimer.
# 
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions, and the following disclaimer in
#    the documentation and/or other materials provided with the
#    distribution.
# 
# 3. Digital Creations requests that attribution be given to Zope
#    in any manner possible. Zope includes a "Powered by Zope"
#    button that is installed by default. While it is not a license
#    violation to remove this button, it is requested that the
#    attribution remain. A significant investment has been put
#    into Zope, and this effort will continue if the Zope community
#    continues to grow. This is one way to assure that growth.
# 
# 4. All advertising materials and documentation mentioning
#    features derived from or use of this software must display
#    the following acknowledgement:
# 
#      "This product includes software developed by Digital Creations
#      for use in the Z Object Publishing Environment
#      (http://www.zope.org/)."
# 
#    In the event that the product being advertised includes an
#    intact Zope distribution (with copyright and license included)
#    then this clause is waived.
# 
# 5. Names associated with Zope or Digital Creations must not be used to
#    endorse or promote products derived from this software without
#    prior written permission from Digital Creations.
# 
# 6. Modified redistributions of any form whatsoever must retain
#    the following acknowledgment:
# 
#      "This product includes software developed by Digital Creations
#      for use in the Z Object Publishing Environment
#      (http://www.zope.org/)."
# 
#    Intact (re-)distributions of any official Zope release do not
#    require an external acknowledgement.
# 
# 7. Modifications are encouraged but must be packaged separately as
#    patches to official Zope releases.  Distributions that do not
#    clearly separate the patches from the original work must be clearly
#    labeled as unofficial distributions.  Modifications which do not
#    carry the name Zope may be packaged in any form, as long as they
#    conform to all of the clauses above.
# 
# 
# Disclaimer
# 
#   THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
#   EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
#   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
#   PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
#   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
#   USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
#   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
#   OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
#   OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
#   SUCH DAMAGE.
# 
# 
# This software consists of contributions made by Digital Creations and
# many individuals on behalf of Digital Creations.  Specific
# attributions are listed in the accompanying credits file.
# 
##############################################################################

# Not only that, but this software is NOT supported by Digital Creations.
# Send comments and questions to mike at digicool.com

__doc__ = "ZDiscussions Base Classes"
__version__ = "0.2.0"

import Globals, OFS, Products, AccessControl
from Products.ZCatalog import ZCatalog
from Acquisition import Implicit
from Globals import HTMLFile, Persistent
from DateTime import DateTime

def manage_addZDTopic(self, id, title, REQUEST=None):
    """Add a ZDTopic object"""

    topic = ZDTopic(id, title)
    self._setObject(id, topic)
    if REQUEST is not None:
	return self.manage_main(self, REQUEST)

class ZDItem(OFS.SimpleItem.SimpleItem,
	     OFS.PropertyManager.PropertyManager,
	     Persistent,
	     Implicit,
	     AccessControl.Role.RoleManager):
    """ZDItem object"""

    meta_type = "Z Discussions Item Base Class"

    _properties = (
	{'id':'title', 'type':'string', 'mode':'w'},
	{'id':'author', 'type':'string', 'mode':'w'},
	{'id':'email', 'type':'string', 'mode':'w'},
	{'id':'body', 'type':'text', 'mode':'w'},
	{'id':'in_reply_to', 'type':'string', 'mode':''}
	)

    manage_options = (
	{'label':'Properties', 'action':'manage_propertiesForm'}
	)

    __ac_permissions__ = (
	('Manage properties', ('manage_addProperty',
			       'manage_editProperties',
			       'manage_delProperties',
			       'manage_changeProperties',)),
	)

    def __init__(self, id, title, body, author, email, in_reply_to):
	self.id = id
	self.title = title
	self.author = author
	self.email = email
	self.body = body
	self.in_reply_to = in_reply_to
	self.created = self.modified = DateTime()

    def ancestors(self):
	"""Return a list of ancestral posts"""
	ancestors = []
	irp = self.in_reply_to
	while irp:
	    parent = getattr(self.aq_parent, irp)
	    ancestors = ancestors + [parent]
	    irp = parent.in_reply_to
	return ancestors

    def children(self, REQUEST=None):
	"""Return a list of replies to this item"""
	if REQUEST is None:
	    REQUEST = self.REQUEST
	children = []
	results = self.searchResults(in_reply_to=self.id) #, sort_on="created")
	children = map(lambda x, self=self, REQUEST=REQUEST:
		        self.getobject(x.data_record_id_, REQUEST),
		       results)
	return children

    def manage_addReply(self, id, title, body, author, email, REQUEST=None):
	"""Add a ZDItem to this ZDTopic"""
    
	item = ZDItem(id, title, body, author, email, self.id)
	self.aq_parent._setObject(id, item)
	if REQUEST is not None:
	    return self.manage_main(self, REQUEST)

    def manage_afterAdd(self, item, container):
	OFS.SimpleItem.SimpleItem.manage_afterAdd(self, item, container)
	self.catalog_object(self, self.absolute_url(1))

    # Am thinkink this is bad -
    # I seem to recall 'self' is not part of the acquisition hierarchy when
    # afterClone is called, resulting in error.  Test.

    def manage_afterClone(self, item, container):
	OFS.SimpleItem.SimpleItem.manage_afterClone(self, item, container)
	self.catalog_object(self, self.absolute_url(1))

    def manage_beforeDelete(self, item, container):
	# Prevent orphans
	for child in self.children():
	    child.in_reply_to = self.in_reply_to
	OFS.SimpleItem.SimpleItem.manage_beforeDelete(self, item, container)
	try:
	    self.uncatalog_object(self.absolute_url(1))
	except ValueError:
	    pass

class ZDTopic(ZCatalog.ZCatalog):
    """ZDTopic object"""

    meta_type = 'Z Discussions Topic Base Class'

    manage_options=(
        {'label': 'Contents',
	 'action': 'manage_main',
	 'target': 'manage_main'},
        
	{'label': 'Cataloged Objects',
	 'action': 'manage_catalogView',
	 'target': 'manage_main'},
        
	{'label': 'MetaData Table',
	 'action': 'manage_catalogSchema',
	 'target':'manage_main'},
        
	{'label': 'Indexes',
	 'action': 'manage_catalogIndexes',
	 'target':'manage_main'},
        
	{'label': 'Status',
	 'action': 'manage_catalogStatus', 
	 'target':'manage_main'},
        )

    def __init__(self, id, title=''):

	# Initialise ZCatalog
	ZCatalog.ZCatalog.__init__(self, id, title)

	# Set up the indexes
	self._catalog.addIndex('body', 'TextIndex')
	self._catalog.addIndex('author', 'FieldIndex')
	self._catalog.addIndex('email', 'FieldIndex')
	self._catalog.addIndex('in_reply_to', 'FieldIndex')
	self._catalog.addIndex('created', 'FieldIndex')
	self._catalog.addIndex('modified', 'FieldIndex')

	# Set up meta-data columns
	self._catalog.addColumn('body')
	self._catalog.addColumn('author')
	self._catalog.addColumn('email')
	self._catalog.addColumn('in_reply_to')
	self._catalog.addColumn('created')
	self._catalog.addColumn('modified')
	
    def manage_editZDTopic(self, title, REQUEST=None):
	"""Set properties of ZDTopic.  Presently just title."""

	self.title = title
	if REQUEST:
	    return self.manage_main(self, REQUEST, manage_tabs_message = "ZDTopic changed.")

    def posts(self, REQUEST=None):
	"""Return the top-level posts"""
	if REQUEST is None:
	    REQUEST=self.REQUEST
	posts = []
	for res in self.searchResults(in_reply_to=''): #, sort_on='created'):
	    posts.append(self.getobject(res.data_record_id_, REQUEST))
	return posts

    children = posts

    def generate_id(self):
	"""Find an available ID"""
	id = 0
	fmt = "%08d"
	while hasattr(self, fmt % id):
	    id = id + 1
	return fmt % id

    def manage_addZDItem(self, id, title, body, author, email, in_reply_to='', REQUEST=None):
	"""Add a ZDItem to this ZDTopic"""
    
	item = ZDItem(id, title, body, author, email, in_reply_to)
	self._setObject(id, item)
	if REQUEST is not None:
	    return self.manage_main(self, REQUEST)


=== Added File Products/ZDBase/__init__.py ===
##############################################################################
# 
# Zope Public License (ZPL) Version 1.0
# -------------------------------------
# 
# Copyright (c) Digital Creations.  All rights reserved.
# 
# This license has been certified as Open Source(tm).
# 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# 
# 1. Redistributions in source code must retain the above copyright
#    notice, this list of conditions, and the following disclaimer.
# 
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions, and the following disclaimer in
#    the documentation and/or other materials provided with the
#    distribution.
# 
# 3. Digital Creations requests that attribution be given to Zope
#    in any manner possible. Zope includes a "Powered by Zope"
#    button that is installed by default. While it is not a license
#    violation to remove this button, it is requested that the
#    attribution remain. A significant investment has been put
#    into Zope, and this effort will continue if the Zope community
#    continues to grow. This is one way to assure that growth.
# 
# 4. All advertising materials and documentation mentioning
#    features derived from or use of this software must display
#    the following acknowledgement:
# 
#      "This product includes software developed by Digital Creations
#      for use in the Z Object Publishing Environment
#      (http://www.zope.org/)."
# 
#    In the event that the product being advertised includes an
#    intact Zope distribution (with copyright and license included)
#    then this clause is waived.
# 
# 5. Names associated with Zope or Digital Creations must not be used to
#    endorse or promote products derived from this software without
#    prior written permission from Digital Creations.
# 
# 6. Modified redistributions of any form whatsoever must retain
#    the following acknowledgment:
# 
#      "This product includes software developed by Digital Creations
#      for use in the Z Object Publishing Environment
#      (http://www.zope.org/)."
# 
#    Intact (re-)distributions of any official Zope release do not
#    require an external acknowledgement.
# 
# 7. Modifications are encouraged but must be packaged separately as
#    patches to official Zope releases.  Distributions that do not
#    clearly separate the patches from the original work must be clearly
#    labeled as unofficial distributions.  Modifications which do not
#    carry the name Zope may be packaged in any form, as long as they
#    conform to all of the clauses above.
# 
# 
# Disclaimer
# 
#   THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
#   EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
#   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
#   PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
#   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
#   USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
#   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
#   OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
#   OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
#   SUCH DAMAGE.
# 
# 
# This software consists of contributions made by Digital Creations and
# many individuals on behalf of Digital Creations.  Specific
# attributions are listed in the accompanying credits file.
# 
##############################################################################

import ZDiscussions

__doc__ = ZDiscussions.__doc__
__version__ = ZDiscussions.__version__

def initialize(context):
     context.registerBaseClass(ZDiscussions.ZDTopic)
     context.registerBaseClass(ZDiscussions.ZDItem)





More information about the zopeorg-checkins mailing list