Commit 4773fac2 authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: Migrate BigFile Document from filesystem.

parent 9eeb4478
......@@ -88,7 +88,7 @@ class BigFile(File):
security.declareProtected(Permissions.AccessContentsInformation,
'getData')
def getData(self):
def getData(self, default=None):
"""Read the full btree
"""
btree = self._baseGetData()
......@@ -103,7 +103,7 @@ class BigFile(File):
"""
self._setContentMd5(None)
def _read_data(self, file, data=None, serialize=True):
def _read_data(self, file, data=None, serialize=True): # pylint: disable=redefined-builtin,arguments-differ
# We might need to make this value configurable. It is important to
# consider the max quantity of object used in the cache. With a default
......@@ -138,11 +138,11 @@ class BigFile(File):
offset = len(btree)
while pos < end:
next = pos + n
if next > end:
next = end
next_ = pos + n
if next_ > end:
next_ = end
btree.write(read(next-pos), offset+pos)
btree.write(read(next_-pos), offset+pos)
pos = file.tell()
if serialize:
......@@ -160,15 +160,15 @@ class BigFile(File):
def _range_request_handler(self, REQUEST, RESPONSE):
# HTTP Range header handling: return True if we've served a range
# chunk out of our data.
range = REQUEST.get_header('Range', None)
range_ = REQUEST.get_header('Range', None)
request_range = REQUEST.get_header('Request-Range', None)
if request_range is not None:
# Netscape 2 through 4 and MSIE 3 implement a draft version
# Later on, we need to serve a different mime-type as well.
range = request_range
range_ = request_range
if_range = REQUEST.get_header('If-Range', None)
if range is not None:
ranges = HTTPRangeSupport.parseRange(range)
if range_ is not None:
ranges = HTTPRangeSupport.parseRange(range_)
data = self._baseGetData()
......@@ -186,11 +186,11 @@ class BigFile(File):
# Date
date = if_range.split( ';')[0]
try: mod_since=long(DateTime(date).timeTime())
except: mod_since=None
except Exception: mod_since=None
if mod_since is not None:
last_mod = self._data_mtime()
if last_mod is None:
last_mod = 0
last_mod = 0
last_mod = long(last_mod)
if last_mod > mod_since:
# Modified, so send a normal response. We delete
......@@ -286,7 +286,7 @@ class BigFile(File):
return True
security.declareProtected(Permissions.View, 'index_html')
def index_html(self, REQUEST, RESPONSE, format=_MARKER, inline=_MARKER, **kw):
def index_html(self, REQUEST, RESPONSE, format=_MARKER, inline=_MARKER, **kw): # pylint: disable=redefined-builtin
"""
Support streaming
"""
......@@ -318,7 +318,7 @@ class BigFile(File):
inline = False
if not inline:
# need to return it as attachment
filename = self.getStandardFilename(format=format)
filename = self.getStandardFilename(format=format) # pylint: disable=unused-variable
RESPONSE.setHeader('Accept-Ranges', 'bytes')
......@@ -337,9 +337,9 @@ class BigFile(File):
self.dav__init(REQUEST, RESPONSE)
self.dav__simpleifhandler(REQUEST, RESPONSE, refresh=1)
type=REQUEST.get_header('content-type', None)
type_=REQUEST.get_header('content-type', None)
file=REQUEST['BODYFILE']
file_=REQUEST['BODYFILE']
content_range = REQUEST.get_header('Content-Range', None)
if content_range is None:
......@@ -347,10 +347,10 @@ class BigFile(File):
self._baseSetData(None)
else:
current_size = int(self.getSize())
query_range = re.compile('bytes \*/\*')
append_range = re.compile('bytes (?P<first_byte>[0-9]+)-' \
'(?P<last_byte>[0-9]+)/' \
'(?P<total_content_length>[0-9]+)')
query_range = re.compile(r'bytes \*/\*')
append_range = re.compile(r'bytes (?P<first_byte>[0-9]+)-' \
'(?P<last_byte>[0-9]+)/' \
'(?P<total_content_length>[0-9]+)')
if query_range.match(content_range):
RESPONSE.setHeader('X-Explanation', 'Resume incomplete')
RESPONSE.setHeader('Range', 'bytes 0-%s' % (current_size-1))
......@@ -383,7 +383,7 @@ class BigFile(File):
RESPONSE.setStatus(400) # Partial content
return RESPONSE
self._appendData(file, content_type=type)
self._appendData(file_, content_type=type_)
RESPONSE.setStatus(204)
return RESPONSE
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Document Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>BigFile</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.Document.BigFile</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>document.erp5.BigFile</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Document Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
document.erp5.BigFile
\ No newline at end of file
erp5_dms
\ No newline at end of file
erp5_dms
erp5_big_file
\ No newline at end of file
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