Exemplo n.º 1
0
    def callback_xmlrpc(self, result):
        """
           Handle callbacks
        """
        tt = getUtility(ITranscodeTool)
        secret = tt.secret()
        try:
            result = eval(decrypt(b64decode(result['key']), secret),
                          {"__builtins__": None}, {})
            assert result.__class__ is dict
        except Exception as e:
            log.error("Unauthorized callback %s" % result)
            return

        if result['profile'] == 'iso' and BURNSTATION_SUPPORT:
            bt = getUtility(IBurnTool)
            if result['path']:
                bt.callback(result)
            else:
                bt.errback(result)
        else:
            if result['path']:
                tt.callback(result)
            else:
                tt.errback(result)
Exemplo n.º 2
0
 def __call__(self):
     try:
         tt = getUtility(ITranscodeTool)
         key = self.request['key']
         input = decrypt(b64decode(key), tt.secret())
         (uid, self.fieldName, profile) = eval(input,
                                               {"__builtins__": None}, {})
         pm = getToolByName(self.context, 'portal_membership')
         newSecurityManager(
             self.request,
             pm.getMemberById(self.context.getOwner().getId()))
         obj = uuidToObject(uid)
         if obj is None:
             log.error('No object for UUID %s', uid)
             return
         field = self._getField(obj)
         if field is None:
             return
         if tt[uid][self.fieldName][profile]['status'] != 'pending':
             log.error('status not pending')
             raise
         return self._getFile(obj, field)
     except Exception as e:
         log.error('Unauthorized file request: %s' % e)
         return
 def __call__(self):
     try: 
         tt = getUtility(ITranscodeTool)
         key = self.request['key']
         input = decrypt(b64decode(key), tt.secret())
         (uid, fieldName, profile) = eval(input, {"__builtins__":None},{})
         obj = self.context.uid_catalog(UID=uid)[0].getObject()
         if not fieldName:
             fieldName = obj.getPrimaryField().getName()
         field = obj.getField(fieldName)
         if tt[uid][fieldName][profile]['status']!='pending':
             log.error('status not pending')
             raise
         pm = getToolByName(self.context, 'portal_membership')
         newSecurityManager(self.request,pm.getMemberById(self.context.getOwner().getId()))
         if field.getFilename(obj).__class__ is unicode:
             # Monkey patch the getFilename to go around plone.app.blob unicode filename bug
             def getFilenameAsString(obj):
                 return field.oldGetFilename(obj).encode(obj.getCharset(),'ignore')
             field.oldGetFilename = field.getFilename
             field.getFilename = getFilenameAsString
             dl = field.download(obj)
             field.getFilename = field.oldGetFilename
             del field.oldGetFilename
             return dl
         else:
             return field.download(obj)
     except Exception as e:
         log.error('Unauthorized file request: %s' % e)
         return
 def __call__(self):
     try:
         tt = getUtility(ITranscodeTool)
         key = self.request['key']
         input = decrypt(b64decode(key), tt.secret())
         (uid, self.fieldName, profile) = eval(input, {"__builtins__":None}, {})
         pm = getToolByName(self.context, 'portal_membership')
         newSecurityManager(self.request,
                            pm.getMemberById(self.context.getOwner().getId()))
         obj = uuidToObject(uid)
         if obj is None:
             log.error('No object for UUID %s', uid)
             return
         field = self._getField(obj)
         if field is None:
             return
         if tt[uid][self.fieldName][profile]['status']!='pending':
             log.error('status not pending')
             raise
         return self._getFile(obj, field)
     except Exception as e:
         log.error('Unauthorized file request: %s' % e)
         return
    def callback_xmlrpc(self, result):
        """
           Handle callbacks
        """
        tt = getUtility(ITranscodeTool)
        secret = tt.secret()
        try:
            result = eval(decrypt(b64decode(result['key']), secret), {"__builtins__":None},{})
            assert result.__class__ is dict
        except Exception as e:
            log.error("Unauthorized callback %s" % result)
            return

        if result['profile'] == 'iso' and BURNSTATION_SUPPORT:
            bt = getUtility(IBurnTool)
            if result['path']:
                bt.callback(result)
            else:
                bt.errback(result)
        else:
            if result['path']:
                tt.callback(result)
            else:
                tt.errback(result)