Commit b94b21d2 authored by 's avatar

Made some bug fixes to import/export.

parent 8752301b
......@@ -105,9 +105,9 @@
Folders are the basic container objects and are analogous to directories.
$Id: Folder.py,v 1.61 1999/02/11 00:49:45 amos Exp $"""
$Id: Folder.py,v 1.62 1999/02/15 23:10:19 brian Exp $"""
__version__='$Revision: 1.61 $'[11:-2]
__version__='$Revision: 1.62 $'[11:-2]
import Globals, SimpleItem, Acquisition, mimetypes, content_types
from Globals import HTMLFile
......@@ -268,24 +268,27 @@ class Folder(ObjectManager, PropertyManager, RoleManager, SimpleItem.Item,
# These methods replace manage_importHack and manage_exportHack
def manage_exportObject(self,id=None,download=None,RESPONSE=None):
def manage_exportObject(self, id='', download=None, RESPONSE=None):
"""Exports an object to a file and returns that file."""
if id is None: o=self
else: o=getattr(self,id)
if not id:
id=self.id
if callable(id): id=id()
ob=self
else: ob=getattr(self,id)
if download:
f=StringIO()
o._p_jar.export_file(o,f)
ob._p_jar.export_file(ob, f)
RESPONSE.setHeader('Content-type','application/data')
RESPONSE.setHeader('Content-Disposition',
'inline;filename=%s.bbe' % id)
return f.getvalue()
f=Globals.data_dir+'/%s.bbe' % id
o._p_jar.export_file(o,f)
ob._p_jar.export_file(ob, f)
if RESPONSE is not None:
return MessageDialog(
title="Object exported",
message="<EM>%s</EM> sucessfully\
exported to <pre>%s</pre>." % (id,f),
exported to <pre>%s</pre>." % (id, f),
action="manage_main")
manage_importExportForm=HTMLFile('importExport',globals())
......@@ -350,7 +353,7 @@ class PUTer(Acquisition.Explicit):
self.id=id
self.__parent__=parent
self.__roles__ =parent.PUT__roles__
def PUT(self, REQUEST, RESPONSE):
"""Adds a document, image or file to the folder when a PUT
request is received."""
......@@ -361,7 +364,7 @@ class PUTer(Acquisition.Explicit):
type, enc=mimetypes.guess_type(name)
if type is None:
if content_types.find_binary(body) >= 0:
raise 'Bad Request', 'Unknown content type'
content_type='application/octet-stream'
else: type=content_types.text_type(body)
type=lower(type)
if type in ('text/html', 'text/xml', 'text/plain'):
......
......@@ -9,21 +9,17 @@
You can export Zope objects to a file in order to transfer
them to a different Zope installation. You can either choose
to download the export file to your local machine, or save it
in Zope's 'var' directory on the server.
in the &quot;var&quot; directory of your Zope installation
on the server.
</P>
<FORM ACTION="manage_exportObject" METHOD="POST"
TARGET="manage_main">
<FORM ACTION="manage_exportObject" METHOD="POST" TARGET="manage_main">
<TABLE CELLSPACING="2">
<TR>
<TH ALIGN="LEFT" VALIGN="TOP">Export object id</TH>
<TD ALIGH="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="id" SIZE="25"
<!--#if ids-->
VALUE="<!--#var "ids[0]"-->">
<!--#else-->
VALUE="">
<!--#/if-->
<INPUT TYPE="TEXT" NAME="id" SIZE="25" VALUE="<!--#if ids--><!--#var
"ids[0]"--><!--#/if-->">
</TD>
</TR>
<TR>
......@@ -31,23 +27,23 @@ TARGET="manage_main">
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="RADIO" NAME="download:int" VALUE="1">
Download to local machine<BR>
<INPUT TYPE="RADIO" NAME="download:int" VALUE="0">
<INPUT TYPE="RADIO" NAME="download:int" VALUE="0" checked>
Save to file on server
</TD>
</TR>
<TR>
<TD></TD>
<TD><BR>
<INPUT TYPE="SUBMIT" VALUE="Export">
</TD>
<TD><INPUT TYPE="SUBMIT" VALUE="Export"></TD>
</TR>
</TABLE>
</FORM>
<P>
You can import Zope objects which have been previously
exported to a file, by placing the file in Zope's 'Import'
directory on the server.
You may import Zope objects which have been previously
exported to a file, by placing the file in the &quot;Import&quot;
directory of your Zope installation on the server. You should create
the &quot;Import&quot; directory in the root of your Zope installation
if it does not yet exist.
</P>
<FORM ACTION="manage_importObject" METHOD="POST"
......@@ -62,11 +58,16 @@ directory on the server.
</TR>
<TR>
<TD></TD>
<TD><BR>
<INPUT TYPE="SUBMIT" VALUE="Import">
<TD><INPUT TYPE="SUBMIT" VALUE="Import">
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
\ No newline at end of file
</HTML>
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