Commit 453b915b authored by matt@zope.com's avatar matt@zope.com

updated transience checkin in proper place ;)

parent 9c8a83d2
...@@ -67,6 +67,8 @@ class DictionaryLike(Interface.Base): ...@@ -67,6 +67,8 @@ class DictionaryLike(Interface.Base):
Merge dictionary d into ourselves. Merge dictionary d into ourselves.
""" """
# DictionaryLike does NOT support copy()
class ItemWithId(Interface.Base): class ItemWithId(Interface.Base):
def getId(self): def getId(self):
""" """
...@@ -178,7 +180,12 @@ class TransientItemContainer(Interface.Base): ...@@ -178,7 +180,12 @@ class TransientItemContainer(Interface.Base):
before expiration. before expiration.
""" """
def setExecuteAfterAddFunc(self, f): def getAddNotificationTarget(self):
"""
Returns the current 'after add' function, or None.
"""
def setAddNotificationTarget(self, f):
""" """
Cause the 'after add' function to be 'f'. Cause the 'after add' function to be 'f'.
...@@ -189,7 +196,12 @@ class TransientItemContainer(Interface.Base): ...@@ -189,7 +196,12 @@ class TransientItemContainer(Interface.Base):
is the item being added to the container. is the item being added to the container.
""" """
def setExecuteBeforeDestructFunc(self, f): def getDelNotificationTarget(self):
"""
Returns the current 'before destruction' function, or None.
"""
def setDelNotificationTarget(self, f):
""" """
Cause the 'before destruction' function to be 'f'. Cause the 'before destruction' function to be 'f'.
...@@ -200,3 +212,38 @@ class TransientItemContainer(Interface.Base): ...@@ -200,3 +212,38 @@ class TransientItemContainer(Interface.Base):
which is the item being destroyed. which is the item being destroyed.
""" """
def notifyAdd(self, item):
"""
Calls the registered ExecuteAfterAdd function on item.
Raises no errors (traps errors).
"""
def notifyDestruct(self, item):
"""
Calls the registered ExecuteBeforeDestruct function on item.
Raises no errors (traps errors).
"""
class TransientNotification(Interface.Base):
"""
Specfies what something must conform to to receive callbacks from
the setExecuteAfterAdd and SetExecuteBeforeDestruct functions. Note
that this isn't a true interface -- the callbacks are registered, not
evaluated by name.
"""
def executeAfterAdd(self, item, context):
"""
Called when an item is added. Item is the item being added,
context is the environment context, where appropriate.
"""
def executeBeforeDestruct(self, item, context):
"""
Called when an item is deleted. Item is the item being deleted,
context is the environment context, where appropriate.
"""
##############################################################################
#
# 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.
#
##############################################################################
"""
Transience initialization routines
$Id: __init__.py,v 1.2 2001/10/22 16:23:51 matt Exp $
"""
import Transience
def initialize(context):
context.registerClass(
Transience.TransientObjectContainer,
permission=Transience.ADD_DATAMGR_PERM,
icon='www/datacontainer.gif',
constructors=(Transience.constructTransientObjectContainerForm,
Transience.constructTransientObjectContainer)
)
context.registerHelp()
<dtml-var manage_page_header>
<dtml-var "manage_form_title(this(), _,
form_title='Add Transient Object Container',
help_product='Transience',
help_topic='Transience.stx'
)">
<FORM ACTION="constructTransientObjectContainer" METHOD="POST">
<TABLE CELLSPACING="2">
<tr>
<div class="form-help">
<p>
Transient Object Containers are used to store transient data in Zope; this
transient data persists, but only for a limited period of time.
</p>
<p>
It is recommended that Transient Object Containers be added to storages which
do not support undo operations; transient objects are write-intensive, and
can generate considerable load on the storage.
</p>
<p>
Transient Object Containers support <b>Notification Targets</b> which
are methods which are invoked when transient objects are added or deleted
from the container. A notification target is invoked with the item being
operated upon, and the transient object container as arguments.
</p>
</div>
</tr>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-label">
Id
</div>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="id" SIZE="20">
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-label">
<em>Title</em>
</div>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="title" SIZE="40">
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-label">
Data object timeout in minutes
</div>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="timeout_mins:int" SIZE="10" value="20">
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-label">
<em>Add Notification Target</em>
</div>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="addNotification" SIZE="40">
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<div class="form-label">
<em>Delete Notification Target</em>
</div>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="delNotification" SIZE="40">
</TD>
</TR>
<TR>
<TD>
</TD>
<TD> <BR><INPUT class="form-element" TYPE="SUBMIT" VALUE=" Add "> </TD>
</TR>
</TABLE>
</FORM>
<dtml-var manage_page_footer>
<dtml-var manage_page_header>
<dtml-var manage_tabs>
<div class="form-help">
Transient object data will be imported/exported to/from the file
'var/transientobjects.zexp' on your server's hard disk in your Zope
directory.
</div>
<br>
<table>
<tr>
<td align="left" valign="top">
<form action="manage_exportTransientObjects" method="post">
<input class="form-element" type=submit name=submit value="Export Transient Objects">
</form>
</td>
<td width="20%">&nbsp;</td>
<td align="left" valign="top">
<form action="manage_importTransientObjects" method="post">
<input class="form-element" type=submit name=submit value="Import Transient Objects">
</form>
</td>
</tr>
</table>
<dtml-var manage_page_footer>
<dtml-var manage_page_header>
<dtml-var manage_tabs>
<table cellspacing="2">
<form action="manage_changeTransientObjectContainer" method="post">
<tr>
<td align="left" valign="top">
<div class="form-label">
<font color="green">
<dtml-let l=getLen>
<dtml-if l>
<dtml-if "l == 1">1 item is in this transient object container.
<dtml-else><dtml-var l> items are in this transient object container.
</dtml-if>
<dtml-else>
There are no items in this transient object container.
</dtml-if>
</dtml-let>
</font>
</div>
</td>
</tr>
<tr>
<td>
&nbsp;
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
<em>Title</em>
</div>
</td>
<td align="left" valign="top">
<input type="text" name="title" size=20 value="&dtml-title;">
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Data object timeout value in minutes
</div>
</td>
<td align="left" valign="top">
<input type="text" name="timeout_mins:int" size=10
value=&dtml-getTimeoutMinutes;>
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
<em>Add Notification Target</em>
</div>
</td>
<td align="left" valign="top".
<input type="text" name="addNotification"
value="&dtml-getAddNotificationTarget;" size=40>
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
<em>Delete Notification Target</em>
</div>
</td>
<td align="left" valign="top".
<input type="text" name="delNotification"
value="&dtml-getDelNotificationTarget;" size=40>
</td>
</tr>
<tr>
<td>
&nbsp;
</td>
</tr>
<tr>
<td align="center" valign="top">
<input class="form-element" type=submit name=submit value=" Change ">
</td>
</tr>
<tr>
<td>
&nbsp;
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
<font color="red">WARNING!</font>
The data objects currently existing in this session data container
will be deleted when the data object timeout is changed.
</div>
</td>
</tr>
</form>
</table>
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment