Commit ae7f1f7f authored by Amos Latteier's avatar Amos Latteier

Added Import/Export machinary to the management interface. Now there is an import/export

tab on Folder management screens. This allows importing from the Import directory and
exporting to the var directory or as a browser download. These facilities replace
manage_importHack and manage_exportHack.
parent 07c90fa5
......@@ -85,8 +85,8 @@
__doc__='''Application support
$Id: Application.py,v 1.87 1999/02/05 18:02:12 jim Exp $'''
__version__='$Revision: 1.87 $'[11:-2]
$Id: Application.py,v 1.88 1999/02/11 00:49:45 amos Exp $'''
__version__='$Revision: 1.88 $'[11:-2]
import Globals,Folder,os,regex,sys,App.Product, App.ProductRegistry
......@@ -192,6 +192,8 @@ class Application(Globals.ApplicationDefaultPermissions, Folder.Folder,
'action':'manage_main', 'target':'manage_main'},
{'icon':'OFS/Properties_icon.gif', 'label':'Properties',
'action':'manage_propertiesForm', 'target':'manage_main'},
{'label':'Import/Export', 'action':'manage_importExportForm',
'target':'manage_main'},
{'icon':'', 'label':'Security',
'action':'manage_access', 'target':'manage_main'},
{'icon':'App/undo_icon.gif', 'label':'Undo',
......
......@@ -105,9 +105,9 @@
Folders are the basic container objects and are analogous to directories.
$Id: Folder.py,v 1.60 1999/02/10 17:21:22 amos Exp $"""
$Id: Folder.py,v 1.61 1999/02/11 00:49:45 amos Exp $"""
__version__='$Revision: 1.60 $'[11:-2]
__version__='$Revision: 1.61 $'[11:-2]
import Globals, SimpleItem, Acquisition, mimetypes, content_types
from Globals import HTMLFile
......@@ -117,8 +117,11 @@ from AccessControl.Role import RoleManager
from CopySupport import CopyContainer
from FindSupport import FindSupport
from Image import Image, File
from string import rfind, lower
from App.Dialogs import MessageDialog
from string import find, rfind, lower
import marshal
from cStringIO import StringIO
import os
manage_addFolderForm=HTMLFile('folderAdd', globals())
......@@ -161,6 +164,8 @@ class Folder(ObjectManager, PropertyManager, RoleManager, SimpleItem.Item,
'target':'manage_main'},
{'label':'Properties', 'action':'manage_propertiesForm',
'target':'manage_main'},
{'label':'Import/Export', 'action':'manage_importExportForm',
'target':'manage_main'},
{'label':'Security', 'action':'manage_access',
'target':'manage_main'},
{'label':'Undo', 'action':'manage_UndoForm',
......@@ -195,6 +200,10 @@ class Folder(ObjectManager, PropertyManager, RoleManager, SimpleItem.Item,
('manage_addProperty', 'manage_editProperties',
'manage_delProperties', 'manage_changeProperties',)),
('FTP access', ('manage_FTPstat','manage_FTPlist')),
('Import/Export objects',
('manage_importObject','manage_importExportForm',
'manage_exportObject')
),
)
......@@ -257,6 +266,45 @@ class Folder(ObjectManager, PropertyManager, RoleManager, SimpleItem.Item,
self._setObject(id,o)
return 'OK, I imported %s' % id
# These methods replace manage_importHack and manage_exportHack
def manage_exportObject(self,id=None,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 download:
f=StringIO()
o._p_jar.export_file(o,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)
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")
manage_importExportForm=HTMLFile('importExport',globals())
def manage_importObject(self,file,REQUEST=None):
"Import an object from a file"
if find(file,'..') != -1:
raise ValueError, 'Bad file name %s' % file
f=os.path.join(INSTANCE_HOME,'Import',file)
o=self._p_jar.import_file(f)
id=o.id
if hasattr(id,'im_func'): id=id()
self._setObject(id,o)
if REQUEST is not None:
return MessageDialog(title='Object imported',
message='<EM>%s</EM> sucessfully imported' % id,
action='manage_main'
)
# FTP support methods
def manage_FTPlist(self,REQUEST):
......
<HTML>
<HEAD>
<TITLE>Import Object</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
<!--#var manage_tabs-->
<P>
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.
</P>
<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-->
</TD>
</TR>
<TR>
<TH ALIGN="LEFT" VALIGN="TOP">Export to</TH>
<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">
Save to file on server
</TD>
</TR>
<TR>
<TD></TD>
<TD><BR>
<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.
</P>
<FORM ACTION="manage_importObject" METHOD="POST"
TARGET="manage_main">
<TABLE CELLSPACING="2">
<TR>
<TH ALIGN="LEFT" VALIGN="TOP">Import file name</TH>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="text" NAME="file" SIZE="25" VALUE="">
</TD>
</TR>
<TR>
<TD></TD>
<TD><BR>
<INPUT TYPE="SUBMIT" VALUE="Import">
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
\ No newline at end of file
......@@ -52,6 +52,7 @@
<INPUT TYPE="SUBMIT" NAME="manage_pasteObjects:method" VALUE="Paste">
<!--#/if-->
<INPUT TYPE="SUBMIT" NAME="manage_delObjects:method" VALUE="Delete">
<INPUT TYPE="SUBMIT" NAME="manage_importExportForm:method" VALUE="Export...">
</TD>
</TR>
</TABLE>
......
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