r252540 - in collective.zipfiletransport/trunk/collective/zipfiletransport: . browser tests utilities
"Encolpe Degoute" <svn-changes-z4DKO/[email protected]> Fri, 13 Sep 2013 09:31:33 +0000 (UTC)
| Newsgroups | gmane.comp.web.zope.plone.collective.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: encolpe
Date: Fri Sep 13 09:31:32 2013
New Revision: 252540
Modified:
collective.zipfiletransport/trunk/collective/zipfiletransport/__init__.py
collective.zipfiletransport/trunk/collective/zipfiletransport/browser/__init__.py
collective.zipfiletransport/trunk/collective/zipfiletransport/browser/common.py
collective.zipfiletransport/trunk/collective/zipfiletransport/browser/foldercontents.py
collective.zipfiletransport/trunk/collective/zipfiletransport/browser/interfaces.py
collective.zipfiletransport/trunk/collective/zipfiletransport/browser/widgets.py
collective.zipfiletransport/trunk/collective/zipfiletransport/browser/zipexport.py
collective.zipfiletransport/trunk/collective/zipfiletransport/browser/zipfiletransportprefs.py
collective.zipfiletransport/trunk/collective/zipfiletransport/browser/zipimport.py
collective.zipfiletransport/trunk/collective/zipfiletransport/config.py
collective.zipfiletransport/trunk/collective/zipfiletransport/interfaces.py
collective.zipfiletransport/trunk/collective/zipfiletransport/schemas.py
collective.zipfiletransport/trunk/collective/zipfiletransport/tests/base.py
collective.zipfiletransport/trunk/collective/zipfiletransport/tests/test_utility.py
collective.zipfiletransport/trunk/collective/zipfiletransport/utilities/__init__.py
collective.zipfiletransport/trunk/collective/zipfiletransport/utilities/interfaces.py
collective.zipfiletransport/trunk/collective/zipfiletransport/utilities/utils.py
Log:
Cleanup trailing spaces and file encoding declaration
Modified: collective.zipfiletransport/trunk/collective/zipfiletransport/__init__.py
==============================================================================
--- collective.zipfiletransport/trunk/collective/zipfiletransport/__init__.py (original)
+++ collective.zipfiletransport/trunk/collective/zipfiletransport/__init__.py Fri Sep 13 09:31:32 2013
@@ -1,20 +1,21 @@
+# -*- coding: utf-8 -*-
##################################################################################
-# Copyright (c) 2004-2009 Utah State University, All rights reserved.
+# Copyright (c) 2004-2009 Utah State University, All rights reserved.
# Portions copyright 2009 Massachusetts Institute of Technology, All rights reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, version 2.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 2.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
##################################################################################
__author__ = '''Brent Lambert, David Ray, Jon Thomas'''
Modified: collective.zipfiletransport/trunk/collective/zipfiletransport/browser/__init__.py
==============================================================================
--- collective.zipfiletransport/trunk/collective/zipfiletransport/browser/__init__.py (original)
+++ collective.zipfiletransport/trunk/collective/zipfiletransport/browser/__init__.py Fri Sep 13 09:31:32 2013
@@ -1,20 +1,21 @@
+# -*- coding: utf-8 -*-
##################################################################################
-# Copyright (c) 2004-2009 Utah State University, All rights reserved.
+# Copyright (c) 2004-2009 Utah State University, All rights reserved.
# Portions copyright 2009 Massachusetts Institute of Technology, All rights reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, version 2.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 2.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
##################################################################################
__author__ = '''Brent Lambert, David Ray, Jon Thomas'''
@@ -31,11 +32,9 @@
class isZipfileImportable(object):
def __call__(self):
- return not IZipfileNotImportable.providedBy(self.context)
+ return not IZipfileNotImportable.providedBy(self.context)
class isZipfileExportable(object):
- def __call__(self):
- return not IZipfileNotExportable.providedBy(self.context)
-
-
+ def __call__(self):
+ return not IZipfileNotExportable.providedBy(self.context)
Modified: collective.zipfiletransport/trunk/collective/zipfiletransport/browser/common.py
==============================================================================
--- collective.zipfiletransport/trunk/collective/zipfiletransport/browser/common.py (original)
+++ collective.zipfiletransport/trunk/collective/zipfiletransport/browser/common.py Fri Sep 13 09:31:32 2013
@@ -1,20 +1,21 @@
+# -*- coding: utf-8 -*-
##################################################################################
-# Copyright (c) 2004-2009 Utah State University, All rights reserved.
+# Copyright (c) 2004-2009 Utah State University, All rights reserved.
# Portions copyright 2009 Massachusetts Institute of Technology, All rights reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, version 2.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 2.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
##################################################################################
__author__ = '''Brent Lambert, David Ray, Jon Thomas'''
@@ -24,9 +25,9 @@
import zope.formlib
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
-try: # >= 4.1
+try: # >= 4.1
from five.formlib.formbase import EditForm
-except ImportError: # < 4.1
+except ImportError: # < 4.1
from Products.Five.formlib.formbase import EditForm
_FORMLIB_DIR = os.path.dirname(zope.formlib.__file__)
Modified: collective.zipfiletransport/trunk/collective/zipfiletransport/browser/foldercontents.py
==============================================================================
--- collective.zipfiletransport/trunk/collective/zipfiletransport/browser/foldercontents.py (original)
+++ collective.zipfiletransport/trunk/collective/zipfiletransport/browser/foldercontents.py Fri Sep 13 09:31:32 2013
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
from zope.component import getMultiAdapter
from zope.interface import implements
from zope.i18n import translate
@@ -23,7 +24,7 @@
"""
"""
implements(IFolderContentsView)
-
+
def contents_table(self):
table = FolderContentsTable(aq_inner(self.context), self.request)
return table.render()
@@ -56,11 +57,11 @@
# Abort if we are at the root of the portal
if IPloneSiteRoot.providedBy(context):
return None
-
+
# Get the parent. If we can't get it (unauthorized), use the portal
parent = aq_parent(obj)
-
+
# # We may get an unauthorized exception if we're not allowed to access#
# the parent. In this case, return None
try:
@@ -72,16 +73,16 @@
if not checkPermission('List folder contents', parent):
return None
-
+
return parent.absolute_url()
except Unauthorized:
- return None
+ return None
class FolderContentsTable(object):
- """
+ """
The foldercontents table renders the table and its actions.
- """
+ """
def __init__(self, context, request, contentFilter={}):
self.context = context
@@ -109,7 +110,7 @@
portal_properties = getToolByName(context, 'portal_properties')
portal_types = getToolByName(context, 'portal_types')
site_properties = portal_properties.site_properties
-
+
use_view_action = site_properties.getProperty('typesUseViewActionInListings', ())
browser_default = context.browserDefault()
@@ -128,7 +129,7 @@
url = obj.getURL()
path = obj.getPath or "/".join(obj.getPhysicalPath())
icon = plone_view.getIcon(obj);
-
+
type_class = 'contenttype-' + plone_utils.normalizeString(
obj.portal_type)
@@ -148,13 +149,13 @@
if obj_type in use_view_action:
view_url = url + '/view'
elif obj.is_folderish:
- view_url = url + "/folder_contents"
+ view_url = url + "/folder_contents"
else:
view_url = url
is_browser_default = len(browser_default[1]) == 1 and (
obj.id == browser_default[1][0])
-
+
results.append(dict(
url = url,
url_href_title = url_href_title,
@@ -189,7 +190,7 @@
@property
def show_sort_column(self):
return self.orderable and self.editable
-
+
@property
def editable(self):
"""
@@ -203,7 +204,7 @@
buttons = []
context = aq_inner(self.context)
portal_actions = getToolByName(context, 'portal_actions')
- button_actions = portal_actions.listActionInfos(object=context, categories=('folder_buttons', ))
+ button_actions = portal_actions.listActionInfos(object=context, categories=('folder_buttons', ))
# Do not show buttons if there is no data, unless there is data to be
# pasted
@@ -211,7 +212,7 @@
for button in button_actions:
# Add Import button to available actions in empty folders
if button['id'] == 'import':
- buttons.append(self.setbuttonclass(button))
+ buttons.append(self.setbuttonclass(button))
if self.context.cb_dataValid():
for button in button_actions:
if button['id'] == 'paste':
Modified: collective.zipfiletransport/trunk/collective/zipfiletransport/browser/interfaces.py
==============================================================================
--- collective.zipfiletransport/trunk/collective/zipfiletransport/browser/interfaces.py (original)
+++ collective.zipfiletransport/trunk/collective/zipfiletransport/browser/interfaces.py Fri Sep 13 09:31:32 2013
@@ -1,20 +1,21 @@
+# -*- coding: utf-8 -*-
##################################################################################
-# Copyright (c) 2004-2009 Utah State University, All rights reserved.
+# Copyright (c) 2004-2009 Utah State University, All rights reserved.
# Portions copyright 2009 Massachusetts Institute of Technology, All rights reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, version 2.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 2.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
##################################################################################
__author__ = '''Brent Lambert, David Ray, Jon Thomas'''
@@ -63,7 +64,7 @@
u"Check this box to overwrite existing files with "
u"the same name. If left unchecked, same named "
u"files will not import."),
- default=False,
+ default=False,
required=False)
excludefromnav = schema.Bool(
Modified: collective.zipfiletransport/trunk/collective/zipfiletransport/browser/widgets.py
==============================================================================
--- collective.zipfiletransport/trunk/collective/zipfiletransport/browser/widgets.py (original)
+++ collective.zipfiletransport/trunk/collective/zipfiletransport/browser/widgets.py Fri Sep 13 09:31:32 2013
@@ -1,20 +1,21 @@
+# -*- coding: utf-8 -*-
##################################################################################
-# Copyright (c) 2004-2009 Utah State University, All rights reserved.
+# Copyright (c) 2004-2009 Utah State University, All rights reserved.
# Portions copyright 2009 Massachusetts Institute of Technology, All rights reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, version 2.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 2.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
##################################################################################
__author__ = '''Brent Lambert, David Ray, Jon Thomas'''
@@ -32,7 +33,7 @@
def __call__(self):
widgettext = TextWidget.__call__(self)
- widgettext += self.context.context.context.restrictedTraverse('@@export_widget')()
+ widgettext += self.context.context.context.restrictedTraverse('@@export_widget')()
return widgettext
Modified: collective.zipfiletransport/trunk/collective/zipfiletransport/browser/zipexport.py
==============================================================================
--- collective.zipfiletransport/trunk/collective/zipfiletransport/browser/zipexport.py (original)
+++ collective.zipfiletransport/trunk/collective/zipfiletransport/browser/zipexport.py Fri Sep 13 09:31:32 2013
@@ -1,20 +1,21 @@
+# -*- coding: utf-8 -*-
##################################################################################
-# Copyright (c) 2004-2009 Utah State University, All rights reserved.
-# Portions copyright 2009 Massachusetts Institute of Technology, All rights reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, version 2.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
+# Copyright (c) 2004-2009 Utah State University, All rights reserved.
+# Portions copyright 2009 Massachusetts Institut of Technology, All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 2.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
##################################################################################
__author__ = '''Brent Lambert, David Ray, Jon Thomas'''
@@ -48,7 +49,7 @@
pass
filename = property(get_zipfile_name, set_zipfile_name)
-
+
class ExportForm(BaseForm):
""" Render the export form """
@@ -66,7 +67,7 @@
self.context = context
self.request = request
self.zft_util = getUtility(
- IZipFileTransportUtility,
+ IZipFileTransportUtility,
name="zipfiletransport")
@@ -99,14 +100,14 @@
zip_path = self.zft_util.exportContent(
context=self.context,
- obj_paths=obj_paths,
+ obj_paths=obj_paths,
filename=filename)
self.context.REQUEST.RESPONSE.setHeader(
- 'content-type',
+ 'content-type',
'application/zip')
self.context.REQUEST.RESPONSE.setHeader(
- 'content-length',
+ 'content-length',
str(os.stat(zip_path)[6]))
self.context.REQUEST.RESPONSE.setHeader(
'Content-Disposition',
@@ -127,11 +128,8 @@
os.unlink(zip_path)
except Exception, e:
logger.warning(
- 'Canr remove %s: %s' %(
+ 'Cannot remove %s: %s' %(
zip_path, e
)
)
return
-
-
-
Modified: collective.zipfiletransport/trunk/collective/zipfiletransport/browser/zipfiletransportprefs.py
==============================================================================
--- collective.zipfiletransport/trunk/collective/zipfiletransport/browser/zipfiletransportprefs.py (original)
+++ collective.zipfiletransport/trunk/collective/zipfiletransport/browser/zipfiletransportprefs.py Fri Sep 13 09:31:32 2013
@@ -1,26 +1,27 @@
+# -*- coding: utf-8 -*-
##################################################################################
-# Copyright (c) 2004-2009 Utah State University, All rights reserved.
+# Copyright (c) 2004-2009 Utah State University, All rights reserved.
# Portions copyright 2009 Massachusetts Institute of Technology, All rights reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, version 2.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 2.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
##################################################################################
__author__ = '''Brent Lambert, David Ray, Jon Thomas'''
__version__ = '$ Revision 0.0 $'[11:-2]
-from zope.interface import Interface, implements
+from zope.interface import Interface, implements
from zope.component import adapts, getUtility
from zope.formlib import form
from zope.schema import TextLine, Bool
@@ -31,40 +32,40 @@
from plone.app.controlpanel.form import ControlPanelForm
-class IZipFileTransportPrefsForm(Interface):
+class IZipFileTransportPrefsForm(Interface):
""" The view for zipfile transport prefs form. """
image_type = TextLine(title=_(u'Image Type'),
description=_(u'Set the image type here. Images imported via ZipFileTransport '
'will be instantiated as an object of this type.'),
required=True)
-
+
file_type = TextLine(title=_(u'File Type'),
description=_(u'Set your file type here. Files imported via ZipFileTransport '
'will be instantiated as an object of this type'),
required=True)
-
+
doc_type = TextLine(title=_(u'Document Type'),
description=_(u'Set your document type here. Documents imported via ZipFileTransport '
'will be instantiated as an object of this type.'),
required=True)
-
+
folder_type = TextLine(title=_(u'Folder Type'),
description=_(u'Set your folderish type here. Folders imported via ZipFileTransport '
'will be instantiated as an object of this type'),
required=True)
-
+
name_by_title = Bool(title=_('Name Objects By Title'),
description=_(u'Use an object''s title as filename in ZIP export instead of ID.'),
required=False)
-
+
class ZipFileTransportControlPanelAdapter(SchemaAdapterBase):
""" Control Panel adapter """
adapts(IPloneSiteRoot)
implements(IZipFileTransportPrefsForm)
-
+
def __init__(self, context):
super(ZipFileTransportControlPanelAdapter, self).__init__(context)
pprop = getUtility(IPropertiesTool)
@@ -76,19 +77,19 @@
def set_image_type(self, image_type):
self.zf_props.image_type = image_type
-
+
def get_file_type(self):
return self.zf_props.file_type
def set_file_type(self, file_type):
self.zf_props.file_type = file_type
-
+
def get_doc_type(self):
return self.zf_props.doc_type
def set_doc_type(self, doc_type):
self.zf_props.doc_type = doc_type
-
+
def get_folder_type(self):
return self.zf_props.folder_type
@@ -97,7 +98,7 @@
def get_name_by_title(self):
return self.zf_props.name_by_title
-
+
def set_name_by_title(self, value):
self.zf_props.name_by_title = value
@@ -106,7 +107,7 @@
doc_type = property(get_doc_type, set_doc_type)
folder_type = property(get_folder_type, set_folder_type)
name_by_title = property(get_name_by_title, set_name_by_title)
-
+
class ZipFileTransportPrefsForm(ControlPanelForm):
""" The view class for the zipfile transport preferences form. """
Modified: collective.zipfiletransport/trunk/collective/zipfiletransport/browser/zipimport.py
==============================================================================
--- collective.zipfiletransport/trunk/collective/zipfiletransport/browser/zipimport.py (original)
+++ collective.zipfiletransport/trunk/collective/zipfiletransport/browser/zipimport.py Fri Sep 13 09:31:32 2013
@@ -1,20 +1,21 @@
+# -*- coding: utf-8 -*-
##################################################################################
-# Copyright (c) 2004-2009 Utah State University, All rights reserved.
+# Copyright (c) 2004-2009 Utah State University, All rights reserved.
# Portions copyright 2009 Massachusetts Institute of Technology, All rights reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, version 2.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 2.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
##################################################################################
__author__ = '''Brent Lambert, David Ray, Jon Thomas'''
@@ -64,7 +65,7 @@
def get_categories(self):
pass
-
+
def set_categories(self):
pass
@@ -83,7 +84,7 @@
class ImportForm(BaseForm):
""" Render the import form """
-
+
implements(IImport)
form_fields = FormFields(IImport)
form_fields['filename'].custom_widget = FileWidget
@@ -96,9 +97,9 @@
self.context = context
self.request = request
self.zft_util = getUtility(
- IZipFileTransportUtility,
+ IZipFileTransportUtility,
name="zipfiletransport")
-
+
@action(_(u'Import'))
def action_import(self, action, data):
file_obj = self.context.REQUEST['form.filename']
@@ -109,14 +110,14 @@
categories = self.context.REQUEST['form.categories']
self.zft_util.importContent(
- file=file_obj,
- context=self.context,
- description=description,
- contributors=contributors,
- overwrite=overwrite,
- categories=categories,
+ file=file_obj,
+ context=self.context,
+ description=description,
+ contributors=contributors,
+ overwrite=overwrite,
+ categories=categories,
excludefromnav=excludefromnav,
)
-
+
self.request.response.redirect('./folder_contents')
Modified: collective.zipfiletransport/trunk/collective/zipfiletransport/config.py
==============================================================================
--- collective.zipfiletransport/trunk/collective/zipfiletransport/config.py (original)
+++ collective.zipfiletransport/trunk/collective/zipfiletransport/config.py Fri Sep 13 09:31:32 2013
@@ -1,20 +1,21 @@
+# -*- coding: utf-8 -*-
##################################################################################
-# Copyright (c) 2004-2009 Utah State University, All rights reserved.
+# Copyright (c) 2004-2009 Utah State University, All rights reserved.
# Portions copyright 2009 Massachusetts Institute of Technology, All rights reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, version 2.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 2.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
##################################################################################
__author__ = '''Brent Lambert, David Ray, Jon Thomas'''
Modified: collective.zipfiletransport/trunk/collective/zipfiletransport/interfaces.py
==============================================================================
--- collective.zipfiletransport/trunk/collective/zipfiletransport/interfaces.py (original)
+++ collective.zipfiletransport/trunk/collective/zipfiletransport/interfaces.py Fri Sep 13 09:31:32 2013
@@ -1,20 +1,21 @@
+# -*- coding: utf-8 -*-
##################################################################################
-# Copyright (c) 2004-2009 Utah State University, All rights reserved.
+# Copyright (c) 2004-2009 Utah State University, All rights reserved.
# Portions copyright 2009 Massachusetts Institute of Technology, All rights reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, version 2.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 2.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
##################################################################################
__author__ = '''Brent Lambert, David Ray, Jon Thomas'''
Modified: collective.zipfiletransport/trunk/collective/zipfiletransport/schemas.py
==============================================================================
--- collective.zipfiletransport/trunk/collective/zipfiletransport/schemas.py (original)
+++ collective.zipfiletransport/trunk/collective/zipfiletransport/schemas.py Fri Sep 13 09:31:32 2013
@@ -1,20 +1,21 @@
+# -*- coding: utf-8 -*-
##################################################################################
-# Copyright (c) 2004-2009 Utah State University, All rights reserved.
+# Copyright (c) 2004-2009 Utah State University, All rights reserved.
# Portions copyright 2009 Massachusetts Institute of Technology, All rights reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, version 2.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 2.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
##################################################################################
__author__ = '''Brent Lambert, David Ray, Jon Thomas'''
@@ -33,5 +34,3 @@
ZipFile(StringIO(value))
except BadZipfile, e:
raise WrongType(e)
-
-
Modified: collective.zipfiletransport/trunk/collective/zipfiletransport/tests/base.py
==============================================================================
--- collective.zipfiletransport/trunk/collective/zipfiletransport/tests/base.py (original)
+++ collective.zipfiletransport/trunk/collective/zipfiletransport/tests/base.py Fri Sep 13 09:31:32 2013
@@ -1,10 +1,11 @@
+# -*- coding: utf-8 -*-
from zope import component
from Products.Five import zcml
from Products.Five import fiveconfigure
from Products.Archetypes.Schema.factory import instanceSchemaFactory
from Products.PloneTestCase import PloneTestCase as ptc
-from Products.PloneTestCase import layer
+from Products.PloneTestCase import layer
SiteLayer = layer.PloneSite
@@ -12,7 +13,7 @@
@classmethod
def setUp(cls):
- """ Set up the additional products required for the
+ """ Set up the additional products required for the
DubletteFinder.
"""
PRODUCTS = [
@@ -24,14 +25,14 @@
import collective.zipfiletransport
zcml.load_config('configure.zcml', collective.zipfiletransport)
fiveconfigure.debug_mode = False
-
+
component.provideAdapter(instanceSchemaFactory)
SiteLayer.setUp()
-
+
class TestCase(ptc.PloneTestCase):
"""Base class used for test cases
"""
- layer = ZipFileTransportLayer
+ layer = ZipFileTransportLayer
Modified: collective.zipfiletransport/trunk/collective/zipfiletransport/tests/test_utility.py
==============================================================================
--- collective.zipfiletransport/trunk/collective/zipfiletransport/tests/test_utility.py (original)
+++ collective.zipfiletransport/trunk/collective/zipfiletransport/tests/test_utility.py Fri Sep 13 09:31:32 2013
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
import os
from zope import component
Modified: collective.zipfiletransport/trunk/collective/zipfiletransport/utilities/__init__.py
==============================================================================
--- collective.zipfiletransport/trunk/collective/zipfiletransport/utilities/__init__.py (original)
+++ collective.zipfiletransport/trunk/collective/zipfiletransport/utilities/__init__.py Fri Sep 13 09:31:32 2013
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
from utils import ZipFileTransportUtility
zipfiletransport_utility = ZipFileTransportUtility("zipfiletransport")
Modified: collective.zipfiletransport/trunk/collective/zipfiletransport/utilities/interfaces.py
==============================================================================
--- collective.zipfiletransport/trunk/collective/zipfiletransport/utilities/interfaces.py (original)
+++ collective.zipfiletransport/trunk/collective/zipfiletransport/utilities/interfaces.py Fri Sep 13 09:31:32 2013
@@ -1,20 +1,21 @@
+# -*- coding: utf-8 -*-
##################################################################################
-# Copyright (c) 2004-2009 Utah State University, All rights reserved.
+# Copyright (c) 2004-2009 Utah State University, All rights reserved.
# Portions copyright 2009 Massachusetts Institute of Technology, All rights reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, version 2.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 2.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
##################################################################################
__author__ = '''Brent Lambert, David Ray, Jon Thomas'''
@@ -29,52 +30,52 @@
"""
Import content from a zip file, creating the folder structure within a ZODB hierarchy.
"""
-
+
def _checkFilePath(self, current_file, path_as_list):
""" Make sure file isn't in a bad folder, if it is skip to the next one. """
-
+
def _createFolderStructure(self, path_as_list, parent):
""" Creates the folder structure given a path_part and parent object """
def _logPage(self, log):
""" Create the log page """
-
+
def _createObject(self, filepath, fdata, parent):
"""
- """
+ """
def _getFileObjectType(self, major, mimetype):
"""
- """
-
+ """
+
def getTime(self,id):
""" Returns the gmtime appended to the an id, used to obtain a unique id for the logFile object """
-
-
+
+
#
# Export content to a zip file.
- #
+ #
# context - Container refers to the container of all the objects that are to be exported.
# obj_paths - Refers to a list of paths of either objects or contexts that will be included in the zip file.
# filename - Refers to the fullpath filename of the exported zip file.
def exportContent(self, context, obj_paths=None, filename=None):
"""
Export content to a zip file.
- """
+ """
def _createObjectList(self, context, obj_paths=None):
"""
Create a list of objects by iteratively descending a folder tree...or trees (if obj_paths is set).
"""
- def GenerateSafeFileName(self, file_name):
+ def GenerateSafeFileName(self, file_name):
"""
Remove illegal characters from the exported filename.
"""
-
+
def _getAllObjectsData(self, objects_listing, context_path):
""" Get the path to a file containing all object data """
-
+
def _objImplementsInterface(self, obj, interfaceClass):
"""
Return boolean indicating if obj implements the given interface.
@@ -93,9 +94,9 @@
#
def getZipFilenames(self, zfile):
""" Gets a list of filenames in the Zip archive."""
-
+
def getZipFileInfo(self, zfile):
""" Gets info about the files in a Zip archive."""
-
+
def getZipFile(self, zfile, filename):
""" Gets a file from the Zip archive."""
Modified: collective.zipfiletransport/trunk/collective/zipfiletransport/utilities/utils.py
==============================================================================
--- collective.zipfiletransport/trunk/collective/zipfiletransport/utilities/utils.py (original)
+++ collective.zipfiletransport/trunk/collective/zipfiletransport/utilities/utils.py Fri Sep 13 09:31:32 2013
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
##################################################################################
# Copyright (c) 2004-2009 Utah State University, All rights reserved.
# Portions copyright 2009 Massachusetts Institute of Technology, All rights reserved.
@@ -390,13 +391,13 @@
# name_by_title has been set. Name by ID is the
# default behavior so that links to other documents
# in documents will be preserved when the same file
- # is imported back into your Plone site. If you use
- # name_by_title, you will be able to save non-ascii
- # chars in the filename but you will not be able to
- # round trip the ZIP archive and have links in your
- # documents continue to work. ID is the preferred
- # solution, as it is much work to go through lots of
- # documents by hand, find the internal links and
+ # is imported back into your Plone site. If you use
+ # name_by_title, you will be able to save non-ascii
+ # chars in the filename but you will not be able to
+ # round trip the ZIP archive and have links in your
+ # documents continue to work. ID is the preferred
+ # solution, as it is much work to go through lots of
+ # documents by hand, find the internal links and
# correct them manually.
filename_path = []
for i in range(0, len(object_path.split('/'))):
@@ -511,28 +512,27 @@
return fileinfo
def getZipFile(self, zfile, filename):
- """ Gets a file from the Zip archive.
- """
- mt = self.mimetypes_registry
- f = ZipFile(zfile)
- finfo = f.getinfo(filename)
- fn = split(finfo.filename)[1] # Get the file name
- path = fn.replace('\\', '/')
- fp = path.split('/') # Split the file path into a list
-
- if '' == fn:
- return 'dir', fn, fp, None, None, 0, None
- ftype = mt.lookupExtension(finfo.filename)
- if not ftype:
- major = 'application'
- mimetype = 'application/octet-stream'
- else:
- major = ftype.major()
- mimetype = ftype.normalized()
- fdata = f.read(filename)
- return 'file', fn, fp, major, mimetype, finfo.file_size, fdata
+ """ Gets a file from the Zip archive.
+ """
+ mt = self.mimetypes_registry
+ f = ZipFile(zfile)
+ finfo = f.getinfo(filename)
+ fn = split(finfo.filename)[1] # Get the file name
+ path = fn.replace('\\', '/')
+ fp = path.split('/') # Split the file path into a list
+
+ if '' == fn:
+ return 'dir', fn, fp, None, None, 0, None
+ ftype = mt.lookupExtension(finfo.filename)
+ if not ftype:
+ major = 'application'
+ mimetype = 'application/octet-stream'
+ else:
+ major = ftype.major()
+ mimetype = ftype.normalized()
+ fdata = f.read(filename)
+ return 'file', fn, fp, major, mimetype, finfo.file_size, fdata
def get_zipfile_name(self):
return 'Test.zip'
-
------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. Consolidate legacy IT systems to a single system of record for IT
2. Standardize and globalize service processes across IT
3. Implement zero-touch automation to replace manual, redundant tasks
http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk