Пример #1
0
def decoApiCallAddDevKey(methodAPI):
    """ Decorator to expand parameter list with devKey"""
    # register additional optional argument devKey 
    registerArgOptional(methodAPI.__name__, 'devKey')
    @wraps(methodAPI)  
    def wrapperAddDevKey(self, *argsPositional, **argsOptional):
        if not ('devKey' in argsOptional):
            argsOptional['devKey'] = self.devKey
        return methodAPI(self, *argsPositional, **argsOptional)
    return wrapperAddDevKey
Пример #2
0
def decoApiCallAddAttachment(methodAPI):
    """ Decorator to expand parameter list with devKey and attachmentfile
        attachmentfile  is a python file descriptor pointing to the file
    """  
    registerArgOptional(methodAPI.__name__, 'devKey')
    registerArgNonApi(methodAPI.__name__, 'attachmentfile')
    @wraps(methodAPI)  
    def wrapperAddAttachment(self, attachmentfile, *argsPositional, **argsOptional):
        if not ('devKey' in argsOptional):
            argsOptional['devKey'] = self.devKey
        argsAttachment = self._getAttachmentArgs(attachmentfile)
        # add additional key/value pairs from argsOptional 
        # although overwrites filename, filetype, content with user definition
        # if they exist
        argsAttachment.update(argsOptional)
        return methodAPI(self, *argsPositional, **argsAttachment)
    return wrapperAddAttachment