Commit b94b21d2 authored by 's avatar

Made some bug fixes to import/export.

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