retreiving the category folder, if provided, or using the default type's folder

Closes #3878
This commit is contained in:
Serghei Mihai 2013-11-20 16:28:13 +01:00
parent 74c6238ae4
commit 2ad10133cc
No known key found for this signature in database
GPG Key ID: 76D1C964BF2FA1AF
1 changed files with 5 additions and 4 deletions

View File

@ -23,10 +23,11 @@ log = logging.getLogger('Plone')
class LoadFromOcr(BrowserView):
output_path = '/mnt/gedimport'
def get_folder(self, doctype):
def get_folder(self, doctype, category_folder):
portal = getToolByName(self.context, 'portal_url').getPortalObject()
folder = portal
for part in themis.config.utils.get_ocr_location(doctype).split('/'):
path = category_folder or themis.config.utils.get_ocr_location(doctype)
for part in path.split('/'):
if not part:
continue
folder = getattr(folder, part)
@ -53,7 +54,7 @@ class LoadFromOcr(BrowserView):
for doctype in ('incoming_mails', 'outgoing_mails',
'internal_documents', 'confidential_documents'):
try:
category, subcategory = \
category, subcategory, category_folder = \
themis.config.utils.get_categories_from_ocr_code(code_cat, doctype)
except TypeError:
continue
@ -62,7 +63,7 @@ class LoadFromOcr(BrowserView):
log.warning('no suitable document type found for %s' % filename)
continue
folder = self.get_folder(doctype)
folder = self.get_folder(doctype, category_folder)
ocr_date = datetime.datetime(
int(date[0:4]), int(date[4:6]), int(date[6:]),