Exemplo n.º 1
0
 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:
         zexp_path = self.request.form.get('zexp_path')
         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
         new_ids = []
         sp = transaction.savepoint()
         try:
             new_ids = zexpcopy.load_zexp(zexp_path, ob)
         except IOError, e:
             sp.rollback()
             error = (('Can not read file with exported data. '
                       'Did you enter correctly the path you received by '
                       'email after export?. Error was: %s') % e.args)
             logger.exception(error)
         except Exception, e:
             sp.rollback()
             error = 'Error importing data from zexp file: %s' % e.args
             logger.exception(error)
             subject = 'Error importing IG Data'
             zexpcopy.send_action_completed_mail(error, sender, to, subject)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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:
         zexp_path = self.request.form.get('zexp_path')
         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
         new_ids = []
         sp = transaction.savepoint()
         try:
             new_ids = zexpcopy.load_zexp(zexp_path, ob)
         except IOError, e:
             sp.rollback()
             error = (('Can not read file with exported data. '
                       'Did you enter correctly the path you received by '
                       'email after export?. Error was: %s') % e.args)
             logger.exception(error)
         except Exception, e:
             sp.rollback()
             error = 'Error importing data from zexp file: %s' % e.args
             logger.exception(error)
             subject = 'Error importing IG Data'
             zexpcopy.send_action_completed_mail(error, sender, to, subject)
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
                error = (('Can not read file with exported data. '
                          'Did you enter correctly the path you received by '
                          'email after export?. Error was: %s') % e.args)
                logger.exception(error)
            except Exception, e:
                sp.rollback()
                error = 'Error importing data from zexp file: %s' % e.args
                logger.exception(error)
                subject = 'Error importing IG Data'
                zexpcopy.send_action_completed_mail(error, sender, to, subject)
            else:
                info = (('The import process ended without errors.'
                        ' Data was imported in this folder, please check: %s')
                        % ob.absolute_url())
                subject = 'IG Data imported successfully'
                zexpcopy.send_action_completed_mail(info, sender, to, subject)
            return zexpcopy_import_zpt.__of__(ctx)(performed=True, ob=ob,
                                                   new_ids=new_ids, info=info,
                                                   error=error, igs=sites,
                                                   macros=tpl_macros)
        else:
            return zexpcopy_import_zpt.__of__(ctx)(performed=False,
                                                   igs=sites,
                                                   macros=tpl_macros)


class ZExpcopyTree(BrowserPage):
    def __call__(self):
        ctx = self.context.aq_inner
        site = ctx.unrestrictedTraverse(self.request.form.get('ig'))
        return zexpcopy_tree_ajax_zpt.__of__(ctx)(site=site)
Exemplo n.º 6
0
                          'Did you enter correctly the path you received by '
                          'email after export?. Error was: %s') % e.args)
                logger.exception(error)
            except Exception, e:
                sp.rollback()
                error = 'Error importing data from zexp file: %s' % e.args
                logger.exception(error)
                subject = 'Error importing IG Data'
                zexpcopy.send_action_completed_mail(error, sender, to, subject)
            else:
                info = (
                    ('The import process ended without errors.'
                     ' Data was imported in this folder, please check: %s') %
                    ob.absolute_url())
                subject = 'IG Data imported successfully'
                zexpcopy.send_action_completed_mail(info, sender, to, subject)
            return zexpcopy_import_zpt.__of__(ctx)(performed=True,
                                                   ob=ob,
                                                   new_ids=new_ids,
                                                   info=info,
                                                   error=error,
                                                   igs=sites,
                                                   macros=tpl_macros)
        else:
            return zexpcopy_import_zpt.__of__(ctx)(performed=False,
                                                   igs=sites,
                                                   macros=tpl_macros)


class ZExpcopyTree(BrowserPage):
    def __call__(self):