[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/Caching/RAMCache/Views/Browser - RAMCacheView.py:1.1 __init__.py:1.1 configure.zcml:1.1 edit.pt:1.1

Albertas Agejevas alga@codeworks.lt
Thu, 31 Oct 2002 11:01:41 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/Caching/RAMCache/Views/Browser
In directory cvs.zope.org:/tmp/cvs-serv24574/RAMCache/Views/Browser

Added Files:
	RAMCacheView.py __init__.py configure.zcml edit.pt 
Log Message:
A port of RAMCacheManager to Zope3.

The current architecture is very much based on the Zope2 RAMCacheManager,
so it might use some refactoring in the future.  For instance, two
different caching interfaces can be derived: one for the data (which does
not care for request) and one for the views (which treats request data in
some special way). The current implementation should work both ways.


=== Added File Zope3/lib/python/Zope/App/Caching/RAMCache/Views/Browser/RAMCacheView.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
# 
##############################################################################
"""RAMCache view

$Id: RAMCacheView.py,v 1.1 2002/10/31 16:01:40 alga Exp $
"""

from Zope.Publisher.Browser.BrowserView import BrowserView
from Zope.App.Caching.RAMCache.IRAMCache import IRAMCache

class RAMCacheView(BrowserView):

    __used_for__ = IRAMCache

    def action(self, request_vars=None, maxEntries=None, maxAge=None,
               cleanupInterval=None):
        self.context.update(request_vars, maxEntries, maxAge,
                            cleanupInterval)
        self.request.response.redirect('.')


=== Added File Zope3/lib/python/Zope/App/Caching/RAMCache/Views/Browser/__init__.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
# 
##############################################################################



=== Added File Zope3/lib/python/Zope/App/Caching/RAMCache/Views/Browser/configure.zcml ===
<zopeConfigure
   xmlns='http://namespaces.zope.org/zope'
   xmlns:browser='http://namespaces.zope.org/browser'
>

  <browser:menuItem menu="add_cache"
      for="Zope.App.OFS.Container.IAdding."
      title="RAM Cache" action="RAMCache"
      description="RAM Cache"/>

  <browser:defaultView for="Zope.App.Caching.RAMCache.IRAMCache." 
		       name="edit.html" />

  <browser:view for="Zope.App.Caching.RAMCache.IRAMCache.IRAMCache"
		factory=".RAMCacheView."
		permission="Zope.Public"
		>
    <browser:page name="editAction.html" attribute="action" />
    <browser:page name="edit.html"       template="edit.pt" />
  </browser:view>

  <browser:menuItems menu="zmi_views" for="Zope.App.Caching.RAMCache.IRAMCache.">
    <browser:menuItem title="Edit" action="edit.html"/>
  </browser:menuItems>

</zopeConfigure>


=== Added File Zope3/lib/python/Zope/App/Caching/RAMCache/Views/Browser/edit.pt ===
<html metal:use-macro="views/standard_macros/page">
  <body>
  <div metal:fill-slot="body">

    <p>You can configure the RAM Cache here.</p>

    <div tal:condition="python: options.has_key('errors') and
                                options['errors']">
      <span style="font-weight: bold">Errors:</span>
      <div tal:repeat="error options/errors | nothing">
        <span tal:replace="python: error[0].title" />:
        <span tal:replace="python: error[1].error_name" />
      </div>
    </div>
    <br />

    <form action="./" method="post" enctype="multipart/form-data">
      <table class="EditTable">
        <tr>
          <th class="EditAttributeName">Request variables</th>
          <td class="EditAttributeValue">
            <textarea name="requestVars:lines"   
	              tal:content="python:'\n'.join(context.requestVars)"/>
            
          </td>
        </tr>
        <tr>
          <th class="EditAttributeName">Maximum cached entries</th>
          <td class="EditAttributeValue">
            <input type="text" name="maxEntries:int"   
	           tal:attributes="value context/maxEntries"/>
            
          </td>
        </tr>
        <tr>
          <th class="EditAttributeName">Maximum age of cached entries</th>
          <td class="EditAttributeValue">
            <input type="text" name="maxAge:int"   
	           tal:attributes="value context/maxAge"/>
            
          </td>
        </tr>
        <tr>
          <th class="EditAttributeName">Time between cache cleanups</th>
          <td class="EditAttributeValue">
            <input type="text" name="cleanupInterval:int"   
	           tal:attributes="value context/cleanupInterval"/>
            
          </td>
        </tr>
      </table>

      <input type="submit" name="editAction.html:method" value="Save Changes" />
      <input type="reset" value="Reset" />
    </form>
    <div tal:replace="options/message|nothing" />

  </div>
  </body>

</html>