'function that uploads a file, or a collection of files, to
the GeoNode'

def upload_file(self, _file):

    if (not self.csrf_token):
        self.login()
    spatial_files = ('dbf_file', 'shx_file', 'prj_file')
    (base, ext) = os.path.splitext(_file)
    params = {'permissions': '{    "users":    {"AnonymousUser":    ["view_resourcebase"]}    ,    "groups":{}}', 'csrfmiddlewaretoken': self.csrf_token}
    if (ext.lower() == '.shp'):
        for spatial_file in spatial_files:
            (ext, _) = spatial_file.split('_')
            file_path = ((base + '.') + ext)
            if os.path.exists(file_path):
                params[spatial_file] = open(file_path, 'rb')
    params['base_file'] = open(_file, 'rb')
    resp = self.make_request(upload_step(), data=params, ajax=True)
    data = resp.read()
    try:
        return (resp, json.loads(data))
    except ValueError:
        raise ValueError(('probably    not    json,    status    %s' % resp.getcode()), data)
