コード例 #1
0
ファイル: utils.py プロジェクト: mrchrisadams/hubplus
def create_resource(top_container, creator, val, f_name, folder) :
    try :
        print "Created by %s" % creator
        title = val.split('.',1)[0]
        name = make_name(title)
        print "Title %s, name %s" % (title,name)
        desc = ''
        license = 'Copyright 2009, Psychosocial Network'
        author = ''
    
        f = File(open('mhpss_export/files/%s'%f_name,'rb'))
    
        resource = get_or_create(creator, top_container,
                             resource=f, title=val, name=name, description=desc,
                             license=license, author=author, stub=False)
        resource.save()
        f.close()
        tag_with_folder_name(resource, creator, folder['title'], 'folder')
        return True
    
    except Exception, e:
        print "******%s",e
        return False
コード例 #2
0
ファイル: utils.py プロジェクト: GunioRobot/hubplus
    desc = ''
    license = 'not specified'
    author = ''

    try:
        f = File(open('mhpss_export/files/%s' % f_name, 'rb'))
    except Exception, e:
        # in at least one case we seem to have a zip file instead of the file refered in the data
        f_name = swap_extension(f_name, 'zip')
        f = File(open('mhpss_export/files/%s' % f_name, 'rb'))

    resource = get_or_create(creator,
                             top_container,
                             resource=f,
                             title=title,
                             name=name,
                             description=desc,
                             license=license,
                             author=author,
                             stub=False)

    resource.save()
    f.close()

    try:
        tag_with(resource, creator, tags, '')
    except Exception, e:
        print e
        ipdb.set_trace()

    return True
コード例 #3
0
ファイル: utils.py プロジェクト: GunioRobot/hubplus
    title = title.split('.',1)[0]
    name = make_name(title)
    print "Title %s, name %s, created by %s" % (title,name,creator.username)
    desc = ''
    license = 'not specified'
    author = ''
    
    try :
        f = File(open('mhpss_export/files/%s'%f_name,'rb'))
    except Exception, e:
        # in at least one case we seem to have a zip file instead of the file refered in the data
        f_name = swap_extension(f_name,'zip')
        f = File(open('mhpss_export/files/%s'%f_name,'rb'))

    resource = get_or_create(creator, top_container,
                                 resource=f, title=title, name=name, description=desc,
                                 license=license, author=author, stub=False)
       

    resource.save()    
    f.close()

    try :
        tag_with(resource, creator, tags, '')
    except Exception, e :
        print e
        ipdb.set_trace()

    return True

from reversion import revision
コード例 #4
0
ファイル: views.py プロジェクト: mrchrisadams/hubplus
def handle_uploaded_file(user, owner, form, f_data) :
    kwargs = dict([(k,v) for k,v in form.cleaned_data.iteritems()])

    resource = get_or_create(user, owner, **kwargs)
    resource.stub= False
    resource.save()