Commit 1df76c1e authored by Hanno Schlichting's avatar Hanno Schlichting

Removed `bobobase_modification_time` from `Persistence.Persistent`, you can...

Removed `bobobase_modification_time` from `Persistence.Persistent`, you can use `DateTime(object._p_mtime)` instead.
parent 7abb893a
...@@ -41,6 +41,9 @@ Features Added ...@@ -41,6 +41,9 @@ Features Added
Restructuring Restructuring
+++++++++++++ +++++++++++++
- Removed `bobobase_modification_time` from `Persistence.Persistent`, you can
use `DateTime(object._p_mtime)` instead.
- Removed `AccessRule` and `SiteRoot` from `Products.SiteAccess`. - Removed `AccessRule` and `SiteRoot` from `Products.SiteAccess`.
- Removed `Products.ZReST` and the `reStructuredText` wrapper, you can use - Removed `Products.ZReST` and the `reStructuredText` wrapper, you can use
......
...@@ -10,28 +10,10 @@ ...@@ -10,28 +10,10 @@
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""Patch for Persistent to support IPersistentExtra.
"""
from DateTime.DateTime import DateTime
class PersistentUtil:
def bobobase_modification_time(self):
jar = self._p_jar
oid = self._p_oid
if jar is None or oid is None:
return DateTime()
try:
t = self._p_mtime
except AttributeError:
t = 0
return DateTime(t)
_patched = False _patched = False
def patchPersistent(): def patchPersistent():
global _patched global _patched
if _patched: if _patched:
...@@ -39,14 +21,6 @@ def patchPersistent(): ...@@ -39,14 +21,6 @@ def patchPersistent():
_patched = True _patched = True
from zope.interface import classImplements
from Persistence import Persistent from Persistence import Persistent
from AccessControl.class_init import InitializeClass from AccessControl.class_init import InitializeClass
from App.interfaces import IPersistentExtra
Persistent.__class_init__ = InitializeClass Persistent.__class_init__ = InitializeClass
for k, v in PersistentUtil.__dict__.items():
if k[0] != '_':
setattr(Persistent, k, v)
classImplements(Persistent, IPersistentExtra)
...@@ -38,16 +38,6 @@ class INavigation(Interface): ...@@ -38,16 +38,6 @@ class INavigation(Interface):
INavigation.setTaggedValue('manage_page_style.css', Attribute(""" """)) INavigation.setTaggedValue('manage_page_style.css', Attribute(""" """))
# XXX: might contain non-API methods and outdated comments;
# not synced with ZopeBook API Reference;
# based on App.PersistentExtra.PersistentUtil
class IPersistentExtra(Interface):
def bobobase_modification_time():
"""
"""
# XXX: might contain non-API methods and outdated comments; # XXX: might contain non-API methods and outdated comments;
# not synced with ZopeBook API Reference; # not synced with ZopeBook API Reference;
# based on App.Undo.UndoSupport # based on App.Undo.UndoSupport
......
import unittest
class TestPersistent(unittest.TestCase):
def test_interfaces(self):
from App.interfaces import IPersistentExtra
from Persistence import Persistent
from zope.interface.verify import verifyClass
from App.PersistentExtra import patchPersistent
patchPersistent()
verifyClass(IPersistentExtra, Persistent)
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(TestPersistent),
))
...@@ -22,6 +22,7 @@ import marshal ...@@ -22,6 +22,7 @@ import marshal
import os import os
import re import re
import sys import sys
import time
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from AccessControl.class_init import InitializeClass from AccessControl.class_init import InitializeClass
...@@ -42,6 +43,7 @@ from App.FactoryDispatcher import ProductDispatcher ...@@ -42,6 +43,7 @@ from App.FactoryDispatcher import ProductDispatcher
from App.Management import Navigation from App.Management import Navigation
from App.Management import Tabs from App.Management import Tabs
from App.special_dtml import DTMLFile from App.special_dtml import DTMLFile
from DateTime import DateTime
from Persistence import Persistent from Persistence import Persistent
from webdav.Collection import Collection from webdav.Collection import Collection
from webdav.Lockable import ResourceLockedError from webdav.Lockable import ResourceLockedError
...@@ -740,7 +742,10 @@ class ObjectManager(CopyContainer, ...@@ -740,7 +742,10 @@ class ObjectManager(CopyContainer,
self, self,
getRoles(self, 'manage_FTPlist', self.manage_FTPlist, ())): getRoles(self, 'manage_FTPlist', self.manage_FTPlist, ())):
mode=mode | 0007 mode=mode | 0007
mtime=self.bobobase_modification_time().timeTime() if hasattr(aq_base(self), '_p_mtime'):
mtime = DateTime(self._p_mtime).timeTime()
else:
mtime = time.time()
# get owner and group # get owner and group
owner=group='Zope' owner=group='Zope'
for user, roles in self.get_local_roles(): for user, roles in self.get_local_roles():
......
...@@ -40,6 +40,7 @@ from App.special_dtml import HTML ...@@ -40,6 +40,7 @@ from App.special_dtml import HTML
from App.special_dtml import DTMLFile from App.special_dtml import DTMLFile
from App.Undo import UndoSupport from App.Undo import UndoSupport
from ComputedAttribute import ComputedAttribute from ComputedAttribute import ComputedAttribute
from DateTime import DateTime
from DocumentTemplate.html_quote import html_quote from DocumentTemplate.html_quote import html_quote
from DocumentTemplate.ustr import ustr from DocumentTemplate.ustr import ustr
from ExtensionClass import Base from ExtensionClass import Base
...@@ -316,8 +317,8 @@ class Item(Base, ...@@ -316,8 +317,8 @@ class Item(Base,
else: else:
size=0 size=0
# get modification time # get modification time
if hasattr(aq_base(self), 'bobobase_modification_time'): if hasattr(aq_base(self), '_p_mtime'):
mtime=self.bobobase_modification_time().timeTime() mtime=DateTime(self._p_mtime).timeTime()
else: else:
mtime=time.time() mtime=time.time()
# get owner and group # get owner and group
......
...@@ -67,18 +67,6 @@ text type and small enough to be edited in a text area. ...@@ -67,18 +67,6 @@ text type and small enough to be edited in a text area.
</td> </td>
</tr> </tr>
<dtml-else> <dtml-else>
<tr>
<td align="left" valign="top">
<div class="form-label">
Last Modified
</div>
</td>
<td align="left" valign="top">
<div class="form-text">
<dtml-var bobobase_modification_time fmt="%Y-%m-%d %H:%M">
</div>
</td>
</tr>
<tr> <tr>
<td align="left" valign="top"> <td align="left" valign="top">
<div class="form-label"> <div class="form-label">
......
...@@ -118,7 +118,6 @@ ...@@ -118,7 +118,6 @@
<SELECT NAME="skey"> <SELECT NAME="skey">
<OPTION VALUE="meta_type">Type <OPTION VALUE="meta_type">Type
<OPTION VALUE="id">Id <OPTION VALUE="id">Id
<OPTION VALUE="bobobase_modification_time">Last Modified
</SELECT> </SELECT>
<INPUT TYPE="checkbox" NAME="rkey" VALUE="reverse"> <INPUT TYPE="checkbox" NAME="rkey" VALUE="reverse">
<span class="form-label"> Reverse?</span> <span class="form-label"> Reverse?</span>
......
...@@ -225,7 +225,6 @@ your search terms below. ...@@ -225,7 +225,6 @@ your search terms below.
<SELECT NAME="skey"> <SELECT NAME="skey">
<OPTION VALUE="id">Id <OPTION VALUE="id">Id
<OPTION VALUE="meta_type">Type <OPTION VALUE="meta_type">Type
<OPTION VALUE="bobobase_modification_time">Last Modified
</SELECT> </SELECT>
<span class="form-label"> <span class="form-label">
<INPUT TYPE="checkbox" NAME="rkey" VALUE="reverse"> Reverse? <INPUT TYPE="checkbox" NAME="rkey" VALUE="reverse"> Reverse?
......
...@@ -52,19 +52,6 @@ button and click <em>upload</em> to update the contents of the &dtml-kind;. ...@@ -52,19 +52,6 @@ button and click <em>upload</em> to update the contents of the &dtml-kind;.
</td> </td>
</tr> </tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Last Modified
</div>
</td>
<td align="left" valign="top">
<div class="form-text">
<dtml-var bobobase_modification_time fmt="%Y-%m-%d %H:%M">
</div>
</td>
</tr>
<tr> <tr>
<td align="left" valign="top"> <td align="left" valign="top">
<div class="form-label"> <div class="form-label">
......
...@@ -92,13 +92,6 @@ function toggleSelect() { ...@@ -92,13 +92,6 @@ function toggleSelect() {
"skey == 'get_size' or rkey == 'get_size'" "skey == 'get_size' or rkey == 'get_size'"
><strong>Size</strong><dtml-else>Size</dtml-if></a></div> ><strong>Size</strong><dtml-else>Size</dtml-if></a></div>
</td> </td>
<td width="19%" align="left"><div class="list-item"><a
href="./manage_main?skey=bobobase_modification_time<dtml-if
"skey == 'bobobase_modification_time' and not rkey"
>&amp;rkey=bobobase_modification_time</dtml-if>"><dtml-if
"skey == 'bobobase_modification_time' or rkey == 'bobobase_modification_time'"
><strong>Last Modified</strong><dtml-else>Last Modified</dtml-if></a></div>
</td>
<dtml-if hasOrderSupport> <dtml-if hasOrderSupport>
<td width="10%" align="left"><div class="list-item"><a <td width="10%" align="left"><div class="list-item"><a
href="./manage_main?skey=position"><dtml-if href="./manage_main?skey=position"><dtml-if
...@@ -157,12 +150,6 @@ function toggleSelect() { ...@@ -157,12 +150,6 @@ function toggleSelect() {
</dtml-try> </dtml-try>
</div> </div>
</td> </td>
<td>
<div class="list-item">
<dtml-var bobobase_modification_time fmt="%Y-%m-%d %H:%M">
</div>
</td>
</dtml-with> </dtml-with>
<dtml-if hasOrderSupport> <dtml-if hasOrderSupport>
......
...@@ -25,14 +25,8 @@ ...@@ -25,14 +25,8 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<td align="left" valign="middle"> <td align="left" valign="middle"></td>
<div class="form-label">Last Modified</div> <td align="left" valign="middle"></td>
</td>
<td align="left" valign="middle">
<div class="form-text"
tal:content="python:context.bobobase_modification_time().strftime('%Y-%m-%d %I:%M %p')">1/1/2000
</div>
</td>
<td align="left" valign="top" colspan="2"> <td align="left" valign="top" colspan="2">
<a href="source.html" tal:condition="context/html">Browse HTML source</a> <a href="source.html" tal:condition="context/html">Browse HTML source</a>
<a href="source.xml" tal:condition="not:context/html">Browse XML source</a> <a href="source.xml" tal:condition="not:context/html">Browse XML source</a>
......
...@@ -86,8 +86,7 @@ class BrowserIdManager(Item, Persistent, Implicit, RoleManager, Owned, Tabs): ...@@ -86,8 +86,7 @@ class BrowserIdManager(Item, Persistent, Implicit, RoleManager, Owned, Tabs):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectPublic() security.declareObjectPublic()
ok = {'meta_type':1, 'id':1, 'title': 1, 'icon':1, ok = {'meta_type': 1, 'id': 1, 'title': 1, 'icon': 1, 'title_or_id': 1}
'bobobase_modification_time':1, 'title_or_id':1 }
security.setDefaultAccess(ok) security.setDefaultAccess(ok)
security.setPermissionDefault(MGMT_SCREEN_PERM, ['Manager']) security.setPermissionDefault(MGMT_SCREEN_PERM, ['Manager'])
security.setPermissionDefault(ACCESS_CONTENTS_PERM,['Manager','Anonymous']) security.setPermissionDefault(ACCESS_CONTENTS_PERM,['Manager','Anonymous'])
......
...@@ -79,8 +79,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs): ...@@ -79,8 +79,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectPublic() security.declareObjectPublic()
ok = {'meta_type':1, 'id':1, 'title': 1, 'icon':1, ok = {'meta_type': 1, 'id': 1, 'title': 1, 'icon': 1, 'title_or_id': 1}
'bobobase_modification_time':1, 'title_or_id':1 }
security.setDefaultAccess(ok) security.setDefaultAccess(ok)
security.setPermissionDefault(CHANGE_DATAMGR_PERM, ['Manager']) security.setPermissionDefault(CHANGE_DATAMGR_PERM, ['Manager'])
security.setPermissionDefault(MGMT_SCREEN_PERM, ['Manager']) security.setPermissionDefault(MGMT_SCREEN_PERM, ['Manager'])
......
...@@ -15,13 +15,6 @@ probably need to manage Zope using its raw IP address to fix things. ...@@ -15,13 +15,6 @@ probably need to manage Zope using its raw IP address to fix things.
<table cellpadding="2" cellspacing="0" width="100%" border="0"> <table cellpadding="2" cellspacing="0" width="100%" border="0">
<dtml-with keyword_args mapping> <dtml-with keyword_args mapping>
<tr>
<td align="left" valign="top" class="form-label">Last Modified</td>
<td align="left" valign="top" class="form-text">
<dtml-var bobobase_modification_time fmt="%Y-%m-%d %H:%M">
</td>
</tr>
<tr> <tr>
<td align="left" valign="top" colspan="2" class="form-help"> <td align="left" valign="top" colspan="2" class="form-help">
Each line represents a path mapping for a single host Each line represents a path mapping for a single host
......
...@@ -44,13 +44,13 @@ class EtagBaseInterface(Interface): ...@@ -44,13 +44,13 @@ class EtagBaseInterface(Interface):
def http__refreshEtag(): def http__refreshEtag():
"""\ """\
While it may make sense to use the ZODB Object Id or While it may make sense to use the ZODB Object Id or the
bobobase_modification_time to generate an Etag, this could database mtime to generate an Etag, this could
fail on certain REQUESTS because: fail on certain REQUESTS because:
o The object is not stored in the ZODB, or o The object is not stored in the ZODB, or
o A Request such as PUT changes the oid or bobobase_modification_time o A Request such as PUT changes the oid or database mtime
*AFTER* the Response has been written out, but the Etag needs *AFTER* the Response has been written out, but the Etag needs
to be updated and returned with the Response of the PUT request. to be updated and returned with the Response of the PUT request.
...@@ -64,7 +64,7 @@ class EtagSupport: ...@@ -64,7 +64,7 @@ class EtagSupport:
function right now is to support the *Lost Updates Problem* by function right now is to support the *Lost Updates Problem* by
allowing Etags and If-Match headers to be checked on PUT calls to allowing Etags and If-Match headers to be checked on PUT calls to
provide a *Seatbelt* style functionality. The Etags is based on provide a *Seatbelt* style functionality. The Etags is based on
the bobobase_modification_time, and thus is updated whenever the the databaes mtime, and thus is updated whenever the
object is updated. If a PUT request, or other HTTP or Dav request object is updated. If a PUT request, or other HTTP or Dav request
comes in with an Etag different than the current one, that request comes in with an Etag different than the current one, that request
can be rejected according to the type of header (If-Match, can be rejected according to the type of header (If-Match,
...@@ -130,15 +130,15 @@ class EtagSupport: ...@@ -130,15 +130,15 @@ class EtagSupport:
# There's no 'if-none-match' header either, so there's no # There's no 'if-none-match' header either, so there's no
# problem continuing with the request # problem continuing with the request
return 1 return 1
elif ('*' in nonelist): elif ('*' in nonematch):
# if-none-match: * means that the operation should not # if-none-match: * means that the operation should not
# be performed if the specified resource exists # be performed if the specified resource exists
# (webdav.NullResource will want to do special behavior # (webdav.NullResource will want to do special behavior
# here) # here)
raise PreconditionFailed raise PreconditionFailed
elif self.http__etag() in nonelist: elif self.http__etag() in nonematch:
# The opposite of if-match, the condition fails # The opposite of if-match, the condition fails
# IF the resources Etag is in the if-none-match list # IF the resources Etag is in the if-none-match list
raise PreconditionFailed raise PreconditionFailed
elif self.http__etag() not in nonelist: elif self.http__etag() not in nonematch:
return 1 return 1
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