'Respond to an incoming push from the peer repository
@param source: the input stream (list of file-like objects)
@param resource: the target resource
@param strategy: the import strategy
@param update_policy: the update policy
@param conflict_policy: the conflict resolution policy
@param onconflict: callback for conflict resolution
@param last_sync: the last synchronization date/time for the peer
@param mixed: negotiate resource with peer (disregard resource)
@return: a dict {status, remote, message, response}, with:
- status....the outcome of the operation
- remote....whether the error was remote (or local)
- message...the log message
- response..the response to send to the peer'

def receive(self, source, resource, strategy=None, update_policy=None, conflict_policy=None, onconflict=None, last_sync=None, mixed=False):

    if ((not resource) or mixed):
        msg = 'Mixed    resource    synchronization    not    supported'
        return {'status': self.log.FATAL, 'remote': False, 'message': msg, 'response': current.xml.json_message(False, 400, msg)}
    repository = self.repository
    ignore_errors = True
    if onconflict:
        onconflict_callback = (lambda item: onconflict(item, repository, resource))
    else:
        onconflict_callback = None
    output = resource.import_xml(source, format='xml', ignore_errors=ignore_errors, strategy=strategy, update_policy=update_policy, conflict_policy=conflict_policy, last_sync=last_sync, onconflict=onconflict_callback)
    log = self.log
    if (resource.error_tree is not None):
        if ignore_errors:
            result = log.WARNING
        else:
            result = log.FATAL
        remote = True
        message = ('%s' % resource.error)
        for element in resource.error_tree.findall('resource'):
            error_msg = element.get('error', 'unknown    error')
            error_fields = element.findall('data[@error]')
            if error_fields:
                for field in error_fields:
                    error_msg = field.get('error', 'unknown    error')
                    if error_msg:
                        msg = ('(UID:    %s)    %s.%s=%s:    %s' % (element.get('uuid', None), element.get('name', None), field.get('field', None), field.get('value', field.text), error_msg))
                        message = ('%s,    %s' % (message, msg))
            else:
                msg = ('(UID:    %s)    %s:    %s' % (element.get('uuid', None), element.get('name', None), error_msg))
                message = ('%s,    %s' % (message, msg))
    else:
        result = log.SUCCESS
        remote = False
        message = 'Data    received    from    peer'
    current.db((current.s3db.sync_repository.id == self.repository.id)).update(last_connected=datetime.datetime.utcnow())
    return {'status': result, 'remote': remote, 'message': message, 'response': output}
