collect error informaiton when updating collection and show in view
This commit is contained in:
parent
8f19077602
commit
cedaf06606
4 changed files with 34 additions and 16 deletions
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2008 Helmut Merz helmutm@cy55.de
|
# Copyright (c) 2012 Helmut Merz helmutm@cy55.de
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -18,8 +18,6 @@
|
||||||
|
|
||||||
"""
|
"""
|
||||||
View class(es) for integrating external objects.
|
View class(es) for integrating external objects.
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from zope import interface, component
|
from zope import interface, component
|
||||||
|
@ -44,5 +42,7 @@ class ExternalCollectionView(ConceptView):
|
||||||
cta = adapted(self.context)
|
cta = adapted(self.context)
|
||||||
if cta is not None:
|
if cta is not None:
|
||||||
cta.update()
|
cta.update()
|
||||||
|
if cta.updateMessage is not None:
|
||||||
|
self.request.form['message'] = cta.updateMessage
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2009 Helmut Merz helmutm@cy55.de
|
# Copyright (c) 2012 Helmut Merz helmutm@cy55.de
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -19,8 +19,6 @@
|
||||||
"""
|
"""
|
||||||
Concept adapter(s) for external collections, e.g. a directory in the
|
Concept adapter(s) for external collections, e.g. a directory in the
|
||||||
file system.
|
file system.
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
@ -62,10 +60,12 @@ class ExternalCollectionAdapter(AdapterBase):
|
||||||
implements(IExternalCollection)
|
implements(IExternalCollection)
|
||||||
adapts(IConcept)
|
adapts(IConcept)
|
||||||
|
|
||||||
_adapterAttributes = ('context', '__parent__', 'exclude', 'newResources')
|
_adapterAttributes = AdapterBase._adapterAttributes + (
|
||||||
|
'exclude', 'newResources', 'updateMessage')
|
||||||
_contextAttributes = list(IExternalCollection) + list(IConcept)
|
_contextAttributes = list(IExternalCollection) + list(IConcept)
|
||||||
|
|
||||||
newResources = None
|
newResources = None
|
||||||
|
updateMessage = None
|
||||||
|
|
||||||
def getExclude(self):
|
def getExclude(self):
|
||||||
return getattr(self.context, '_exclude', None) or []
|
return getattr(self.context, '_exclude', None) or []
|
||||||
|
@ -102,11 +102,15 @@ class ExternalCollectionAdapter(AdapterBase):
|
||||||
directory = provider.getDirectory(self)
|
directory = provider.getDirectory(self)
|
||||||
adobj.storageParams=dict(subdirectory=directory)
|
adobj.storageParams=dict(subdirectory=directory)
|
||||||
adobj.externalAddress = addr
|
adobj.externalAddress = addr
|
||||||
|
# collect error information
|
||||||
|
if adobj.processingErrors:
|
||||||
|
message = self.updateMessage or u''
|
||||||
|
message += u'<br />'.join(adobj.processingErrors)
|
||||||
|
self.updateMessage = message
|
||||||
# force reindexing
|
# force reindexing
|
||||||
notify(ObjectModifiedEvent(obj))
|
notify(ObjectModifiedEvent(obj))
|
||||||
else:
|
else:
|
||||||
new.append(addr)
|
new.append(addr)
|
||||||
#print '*** new', new
|
|
||||||
if new:
|
if new:
|
||||||
self.newResources = provider.createExtFileObjects(self, new)
|
self.newResources = provider.createExtFileObjects(self, new)
|
||||||
for r in self.newResources:
|
for r in self.newResources:
|
||||||
|
@ -206,6 +210,11 @@ class DirectoryCollectionProvider(object):
|
||||||
)
|
)
|
||||||
adobj = adapted(obj)
|
adobj = adapted(obj)
|
||||||
adobj.externalAddress = addr # must be set last
|
adobj.externalAddress = addr # must be set last
|
||||||
|
# collect error information
|
||||||
|
if adobj.processingErrors:
|
||||||
|
message = client.updateMessage or u''
|
||||||
|
message += u'<br />'.join(adobj.processingErrors)
|
||||||
|
client.updateMessage = message
|
||||||
yield obj
|
yield obj
|
||||||
|
|
||||||
def getDirectory(self, client):
|
def getDirectory(self, client):
|
||||||
|
|
|
@ -7,6 +7,10 @@
|
||||||
<metal:block use-macro="view/concept_macros/conceptdata">
|
<metal:block use-macro="view/concept_macros/conceptdata">
|
||||||
<metal:fill tal:condition="item/editable"
|
<metal:fill tal:condition="item/editable"
|
||||||
fill-slot="fields">
|
fill-slot="fields">
|
||||||
|
<div class="error"
|
||||||
|
tal:define="message view/message | request/message | nothing"
|
||||||
|
tal:condition="message"
|
||||||
|
tal:content="structure message" />
|
||||||
<metal:block use-macro="view/concept_macros/conceptfields" />
|
<metal:block use-macro="view/concept_macros/conceptfields" />
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<input type="submit" name="update" value="Update Collection" />
|
<input type="submit" name="update" value="Update Collection" />
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2010 Helmut Merz helmutm@cy55.de
|
# Copyright (c) 2012 Helmut Merz helmutm@cy55.de
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -18,8 +18,6 @@
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Resource adapter(s) for MS Office files.
|
Resource adapter(s) for MS Office files.
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from datetime import date, datetime, timedelta
|
from datetime import date, datetime, timedelta
|
||||||
|
@ -54,11 +52,16 @@ class OfficeFile(ExternalFileAdapter):
|
||||||
|
|
||||||
implements(IOfficeFile)
|
implements(IOfficeFile)
|
||||||
|
|
||||||
|
_adapterAttributes = ExternalFileAdapter._adapterAttributes + (
|
||||||
|
'processingErrors',)
|
||||||
|
|
||||||
propertyMap = {u'Revision:': 'version'}
|
propertyMap = {u'Revision:': 'version'}
|
||||||
propFileName = 'docProps/custom.xml'
|
propFileName = 'docProps/custom.xml'
|
||||||
fileExtensions = ('.docm', '.docx', 'dotm', 'dotx', 'pptx', 'potx', 'ppsx',
|
fileExtensions = ('.docm', '.docx', 'dotm', 'dotx', 'pptx', 'potx', 'ppsx',
|
||||||
'.xlsm', '.xlsx', '.xltm', '.xltx')
|
'.xlsm', '.xlsx', '.xltm', '.xltx')
|
||||||
|
|
||||||
|
processingErrors = []
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def logger(self):
|
def logger(self):
|
||||||
return getLogger('loops.integrator.office.base.OfficeFile')
|
return getLogger('loops.integrator.office.base.OfficeFile')
|
||||||
|
@ -136,7 +139,9 @@ class OfficeFile(ExternalFileAdapter):
|
||||||
newZf.writestr(self.propFileName, etree.tostring(dom))
|
newZf.writestr(self.propFileName, etree.tostring(dom))
|
||||||
newZf.close()
|
newZf.close()
|
||||||
shutil.move(newFn, fn)
|
shutil.move(newFn, fn)
|
||||||
self.update(attributes)
|
errors = self.update(attributes)
|
||||||
|
if errors:
|
||||||
|
self.processingErrors = errors
|
||||||
|
|
||||||
def update(self, attributes):
|
def update(self, attributes):
|
||||||
# to be implemented by subclass
|
# to be implemented by subclass
|
||||||
|
@ -146,10 +151,10 @@ class OfficeFile(ExternalFileAdapter):
|
||||||
def parseDate(s):
|
def parseDate(s):
|
||||||
if not s:
|
if not s:
|
||||||
return None
|
return None
|
||||||
|
try:
|
||||||
tt = strptime(s, '%Y-%m-%dT%H:%M:%SZ')
|
tt = strptime(s, '%Y-%m-%dT%H:%M:%SZ')
|
||||||
#try:
|
except ValueError:
|
||||||
# tt = strptime(s, '%Y-%m-%dT%H:%M:%SZ')
|
return None
|
||||||
#except ValueError:
|
|
||||||
# try:
|
# try:
|
||||||
# tt = strptime(s, '%d.%m.%y')
|
# tt = strptime(s, '%d.%m.%y')
|
||||||
# except ValueError:
|
# except ValueError:
|
||||||
|
|
Loading…
Add table
Reference in a new issue