def __call__(self): ctx = self.context.aq_inner info = error = '' sites = ctx.objectValues([METATYPE_NYSITE, METATYPE_GROUPWARESITE]) sites = [(s.getId(), s.title_or_id()) for s in sites] sites.sort(key=operator.itemgetter(0)) submit = self.request.form.get('submit') if submit: path = self.request.form.get('location') ig_id = self.request.form.get('ig') ob = ctx.unrestrictedTraverse('/%s/%s' % (ig_id, path)) sender = ctx.applications.mail_from to = self.request.AUTHENTICATED_USER.mail try: zexp_path = zexpcopy.write_zexp(ob) except Exception, e: zexp_path = '' error = "Error while exporting %s IG Data: %s" % (ig_id, e.args) zexpcopy.send_export_completed_mail(error, sender, to) else: info = zexpcopy.export_completed_message_zpt.__of__(ctx)(zexp_path=zexp_path, ob_url=ob.absolute_url()) zexpcopy.send_export_completed_mail(info, sender, to) options = { 'performed': True, 'zexp_path': zexp_path, 'info': info.replace('\n', '<br />\n'), 'error': error, 'igs': sites, } return zexpcopy_export_zpt.__of__(ctx)(**options)
def test_write_load_zexp(self): ob = self.portal.info path = zexpcopy.write_zexp(ob) object_ids = ob.objectIds() self.portal._delObject('info') zexpcopy.load_zexp(path, self.portal) self.assertEqual(self.portal.info.objectIds(), object_ids)
def test_write_zexp(self): config = getConfiguration() ob = self.portal.info path = zexpcopy.write_zexp(ob) self.assertEqual( path, os.path.join(config.clienthome, '%s.zexp' % ob.getId())) self.assertTrue(os.path.isfile(path))
def test_write_zexp(self): config = getConfiguration() ob = self.portal.info path = zexpcopy.write_zexp(ob) self.assertEqual(path, os.path.join(config.clienthome, '%s.zexp' % ob.getId())) self.assertTrue(os.path.isfile(path))
def __call__(self): ctx = self.context.aq_inner info = error = '' sites = ctx.objectValues([METATYPE_NYSITE, METATYPE_GROUPWARESITE]) sites = [(s.getId(), s.title_or_id()) for s in sites] sites.sort(key=operator.itemgetter(0)) submit = self.request.form.get('submit') if submit: path = self.request.form.get('location') ig_id = self.request.form.get('ig') ob = ctx.unrestrictedTraverse('/%s/%s' % (ig_id, path)) sender = ctx.applications.mail_from to = self.request.AUTHENTICATED_USER.mail try: zexp_path = zexpcopy.write_zexp(ob) except Exception, e: zexp_path = '' error = "Error while exporting %s IG Data: %s" % (ig_id, e.args) logger.exception(error) subject = 'Error exporting IG Data' zexpcopy.send_action_completed_mail(error, sender, to, subject) else: info = zexpcopy.export_completed_message_zpt.__of__(ctx)( zexp_path=zexp_path, ob_url=ob.absolute_url()) subject = 'IG Data exported successfully' zexpcopy.send_action_completed_mail(info, sender, to, subject) options = { 'performed': True, 'zexp_path': zexp_path, 'info': info.replace('\n', '<br />\n'), 'error': error, 'igs': sites, 'macros': tpl_macros, } return zexpcopy_export_zpt.__of__(ctx)(**options)