[Zope-Checkins] CVS: Zope/lib/python/OFS - Application.py:1.155.4.1 CopySupport.py:1.72.6.1 History.py:1.8.8.1 ObjectManager.py:1.137.8.1 PropertySheets.py:1.74.8.1 SimpleItem.py:1.90.8.1 Uninstalled.py:1.10.40.1
Shane Hathaway
shane@digicool.com
Thu, 9 Aug 2001 13:34:03 -0400
Update of /cvs-repository/Zope/lib/python/OFS
In directory cvs.zope.org:/tmp/cvs-serv29115/lib/python/OFS
Modified Files:
Tag: NR-branch
Application.py CopySupport.py History.py ObjectManager.py
PropertySheets.py SimpleItem.py Uninstalled.py
Log Message:
Sync NR-branch with trunk. Sorry about so many checkin messages...
=== Zope/lib/python/OFS/Application.py 1.155 => 1.155.4.1 ===
self,
'standard_html_header',
- 'Standard Html Header',
- '<HTML><HEAD><TITLE><dtml-var title_or_id>' \
- '</TITLE></HEAD><BODY BGCOLOR="#FFFFFF">')
+ 'Standard Html Header', (
+ '<html><head><title>&dtml-title_or_id;'
+ '</title></head><body bgcolor="#FFFFFF">') )
Document.manage_addDocument(
self,
'standard_html_footer',
'Standard Html Footer',
- '</BODY></HTML>')
+ '</body></html>')
Document.manage_addDocument(
self,
'standard_error_message',
=== Zope/lib/python/OFS/CopySupport.py 1.72 => 1.72.6.1 ===
=== Zope/lib/python/OFS/History.py 1.8 => 1.8.8.1 ===
import Globals, ndiff, ExtensionClass
from DateTime import DateTime
-from Acquisition import Implicit
+from Acquisition import Implicit, aq_base
from string import join, split, atoi, strip
from struct import pack, unpack
from cgi import escape
@@ -213,10 +213,12 @@
self.manage_beforeHistoryCopy()
state=self._p_jar.oldstate(self, serial)
# Scrub the object before restoring the old state
- self._p_changed=0
- self._p_deactivate()
- self.__setstate__(state)
- self._p_changed=1
+ base = aq_base(self)
+ base._p_changed=0
+ base._p_deactivate()
+ base.__setstate__(state)
+ base._p_changed=1
+
self.manage_afterHistoryCopy()
if RESPONSE is not None and URL1 is not None:
=== Zope/lib/python/OFS/ObjectManager.py 1.137 => 1.137.8.1 ===
}
-bad_id=re.compile(r'[^a-zA-Z0-9-_~,. ]').search #TS
+bad_id=re.compile(r'[^a-zA-Z0-9-_~,.$# ]').search #TS
# Global constants: __replaceable__ flags:
NOT_REPLACEABLE = 0
@@ -234,6 +234,7 @@
gmt = []
for entry in Products.meta_types:
+
if interfaces is None:
if entry.get("visibility", None) == "Global":
gmt.append(entry)
@@ -520,7 +521,7 @@
return r
def manage_exportObject(self, id='', download=None, toxml=None,
- RESPONSE=None):
+ RESPONSE=None,REQUEST=None):
"""Exports an object to a file and returns that file."""
if not id:
# can't use getId() here (breaks on "old" exported objects)
@@ -546,12 +547,13 @@
XMLExportImport.exportXML(ob._p_jar, ob._p_oid, f)
else:
ob._p_jar.exportFile(ob._p_oid, f)
- if RESPONSE is not None:
- return MessageDialog(
- title="Object exported",
- message="<EM>%s</EM> sucessfully\
- exported to <pre>%s</pre>." % (id, f),
- action="manage_main")
+
+ if REQUEST is not None:
+ return self.manage_main(self, REQUEST,
+ manage_tabs_message=
+ '<em>%s</em> sucessfully exported to <em>%s</em>' % (id,f),
+ title = 'Object exported')
+
manage_importExportForm=DTMLFile('dtml/importExport',globals())
@@ -594,11 +596,11 @@
ob.manage_changeOwnershipType(explicit=0)
if REQUEST is not None:
- return MessageDialog(
- title='Object imported',
- message='<EM>%s</EM> sucessfully imported' % id,
- action='manage_main'
- )
+ return self.manage_main(self, REQUEST,
+ manage_tabs_message='<em>%s</em> sucessfully imported' % id,
+ title = 'Object imported',
+ update_menu=1)
+
# FTP support methods
=== Zope/lib/python/OFS/PropertySheets.py 1.74 => 1.74.8.1 ===
# Quote non-xml items here?
attrs=''
- prop=' <n:%s%s><![CDATA[%s]]></n:%s>' % (name, attrs, value, name)
+
+ prop=' <n:%s%s>%s</n:%s>' % (name, attrs, xml_escape(value), name)
+
result.append(prop)
if not result: return ''
result=join(result, '\n')
@@ -535,7 +537,7 @@
{'id':'supportedlock', 'mode':'r'},
{'id':'lockdiscovery', 'mode':'r'},
)
-
+
def getProperty(self, id, default=None):
method='dav__%s' % id
if not hasattr(self, method):
@@ -804,3 +806,18 @@
if callable(attr):
return attr()
return attr
+
+
+def xml_escape(v):
+ """ convert any content from ISO-8859-1 to UTF-8
+ The main use is to escape non-US object property values
+ (e.g. containing accented characters). Also we convert "<" and ">"
+ to entities to keep the properties XML compliant.
+ """
+ v = str(v)
+
+ if v.count('<') != v.count('>'):
+ v = v.replace('<','<')
+ v = v.replace('>','>')
+
+ return unicode(v,"latin-1").encode("utf-8")
=== Zope/lib/python/OFS/SimpleItem.py 1.90 => 1.90.8.1 ===
client = client.aq_parent
s=getattr(client, 'standard_error_message')
- v=HTML.__call__(s, client, REQUEST, error_type=error_type,
- error_value=error_value,
- error_tb=error_tb,error_traceback=error_tb,
- error_message=error_message)
+ kwargs = {'error_type': error_type,
+ 'error_value': error_value,
+ 'error_tb': error_tb,
+ 'error_traceback': error_tb,
+ 'error_message': error_message}
+ if isinstance(s, HTML):
+ v = s(client, REQUEST, **kwargs)
+ elif callable(s):
+ v = s(**kwargs)
+ else:
+ v = HTML.__call__(s, client, REQUEST, **kwargs)
except: v = error_value or "Sorry, an error occurred"
raise error_type, v, tb
finally:
=== Zope/lib/python/OFS/Uninstalled.py 1.10 => 1.10.40.1 ===
from Acquisition import Acquired
import Persistence
+from thread import allocate_lock
+from zLOG import LOG, WARNING
broken_klasses={}
+broken_klasses_lock = allocate_lock()
class BrokenClass(Acquisition.Explicit, SimpleItem.Item,
Persistence.Overridable):
@@ -117,30 +120,33 @@
manage_workspace=manage
-def Broken(self, oid, klass):
- if broken_klasses.has_key(klass):
- klass=broken_klasses[klass]
- else:
- module, klass = klass
- d={'BrokenClass': BrokenClass}
- exec ("class %s(BrokenClass): ' '; __module__=%s"
- % (klass, `module`)) in d
- broken_klasses[klass]=d[klass]
- klass=d[klass]
- module=string.split(module,'.')
- if len(module) > 2 and module[0]=='Products':
- klass.product_name= module[1]
- klass.title=(
- 'This object from the %s product '
- 'is broken!' %
- klass.product_name)
- klass.info=(
- 'This object\'s class was %s in module %s.' %
- (klass.__name__, klass.__module__))
-
+def Broken(self, oid, pair):
+ broken_klasses_lock.acquire()
+ try:
+ if broken_klasses.has_key(pair):
+ klass = broken_klasses[pair]
+ else:
+ module, klassname = pair
+ d={'BrokenClass': BrokenClass}
+ exec ("class %s(BrokenClass): ' '; __module__=%s"
+ % (klassname, `module`)) in d
+ klass = broken_klasses[pair] = d[klassname]
+ module=string.split(module,'.')
+ if len(module) > 2 and module[0]=='Products':
+ klass.product_name= module[1]
+ klass.title=(
+ 'This object from the %s product '
+ 'is broken!' %
+ klass.product_name)
+ klass.info=(
+ 'This object\'s class was %s in module %s.' %
+ (klass.__name__, klass.__module__))
+ LOG('ZODB', WARNING, 'Could not import class %s '
+ 'from module %s' % (`klass.__name__`, `klass.__module__`))
+ finally:
+ broken_klasses_lock.release()
if oid is None: return klass
i=klass()
i._p_oid=oid
i._p_jar=self
return i
-