当前位置: 首页>>代码示例>>Python>>正文


Python Project.get方法代码示例

本文整理汇总了Python中project.model.Project.get方法的典型用法代码示例。如果您正苦于以下问题:Python Project.get方法的具体用法?Python Project.get怎么用?Python Project.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在project.model.Project的用法示例。


在下文中一共展示了Project.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: download_export

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import get [as 别名]
def download_export(project_id,entry_id,export_type):
    project = Project()
    project.get(project_id)
    metadata = project.get_exported_file(entry_id,export_type)
    file_ = project.get_datafile(str(metadata['file_id']))
    response = make_response(file_.read())
    response.headers['Content-Description'] = 'Uploaded File'
    response.headers['Content-Type'] = 'application/%s' % file_.content_type
    response.headers['Content-Length'] = file_.length
    response.headers['Content-Disposition'] = 'attachment; filename=%s' % file_.filename
    return response 
开发者ID:sweemeng,项目名称:scrapedump,代码行数:13,代码来源:action.py

示例2: export_single

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import get [as 别名]
def export_single(project_id, entry_id, export_type):
    project = Project()
    project.get(project_id)
    exporter_list = {"json": JSONExporter, "csv": FlatCSVExporter}
    if export_type == "json":
        exporter = JSONExporter(project)
    elif export_type == "csv":
        exporter = FlatCSVExporter(project)
    else:
        raise "bad exporter"
    exporter.export(entry_id)
开发者ID:sweemeng,项目名称:scrapedump,代码行数:13,代码来源:data_exporter.py

示例3: get_data_upload

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import get [as 别名]
def get_data_upload(project_id,entry_id,file_id):
    # this will allow download of the file. 
    project = Project()
    project.get(project_id)
    metadata = project.get_datafile_metadata(entry_id,file_id)
    response = make_response(project.get_datafile(file_id).read())
    response.headers['Content-Description'] = 'Uploaded File'
    response.headers['Content-Type'] = 'application/%s' % metadata['filename'].split('.')[-1]
    response.headers['Content-Length'] = metadata['size']
    response.headers['Content-Disposition'] = 'attachment; filename=%s' % metadata['filename']
    return response 
开发者ID:sweemeng,项目名称:scrapedump,代码行数:13,代码来源:action.py

示例4: delete_data_upload

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import get [as 别名]
def delete_data_upload(project_id,entry_id,file_id):
    project = Project()
    project.get(project_id)
    try:
        project.delete_datafile(entry_id,file_id) 
        status = {'status':'Success','message':'completed'}
    except:
        status = {'status':'Failed','message':'error deleting file'}
        
    
    return jsonify([status])
开发者ID:sweemeng,项目名称:scrapedump,代码行数:13,代码来源:action.py

示例5: add_entry

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import get [as 别名]
def add_entry(project_id):
    form = EntryForm(csrf_enabled=False)
    if form.validate_on_submit():
        project = Project()
        project.get(project_id)
        name = form.name.data
        description  = form.description.data
        short_name = form.description.data
        source = form.description.data
        project.add_entry(name,description,source)
        return redirect('/project/%s' % project_id)
    return render_template('entry_create.html',form=form)
开发者ID:sweemeng,项目名称:scrapedump,代码行数:14,代码来源:action.py

示例6: get

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import get [as 别名]
    def get(self, project_id, entry, entry_id):
        project = Project()
        project.get(project_id)
        model = project.get_entry_collection(entry)
        if entry_id:
            id = objectid.ObjectId(str(entry_id))
            result = model.query({"_id": id})
        else:
            result = model.all()

        data = json.dumps(result, default=bson.json_util.default)
        resp = Response(data, status=200, mimetype="application/json")
        resp.headers["Link"] = "http://localhost:5000"
        return resp
开发者ID:sweemeng,项目名称:scrapedump,代码行数:16,代码来源:data.py

示例7: get_entry

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import get [as 别名]
def get_entry(project_id,entry):
    form = EntryUpdateForm()
    edit = False
    # entry should be short_name
    if form.validate_on_submit():
        project = Project()
        description = form.description.data
        source = form.source.data
        project.get(project_id)
        project.update_entry(entry,description,source)
        return redirect('/entry/%s/%s/' % (project_id,entry))
    project = Project()
    project.find(project_name)
    return render_template('entry_view.html',project=project,entry=entry,
                           edit=edit,form=form)
开发者ID:sweemeng,项目名称:scrapedump,代码行数:17,代码来源:action.py

示例8: project_entry_create

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import get [as 别名]
def project_entry_create(project_id):
    form = EntryForm(csrf_enabled=False)
    edit = False
    project = Project()
    project.get(project_id)
    permission = EditProjectPermission(project_id)
    if not permission.can():
        abort(403)
    if form.validate_on_submit():
        name = form.name.data
        description = form.description.data
        source = form.source.data
        entry_id = project.add_entry(name,description,source)
        return redirect('/project/%s/' % (project_id))
        
    return render_template('entry_create.html',form=form)
开发者ID:sweemeng,项目名称:scrapedump,代码行数:18,代码来源:action.py

示例9: delete

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import get [as 别名]
    def delete(self, project_id, entry, entry_id):
        api_key = request.args.get("api_key")
        if not authorized(api_key, project_id):
            return jsonify({"status": False})

        # if project not in user.user.project:
        #    return jsonify({'status':False})

        id = objectid.ObjectId(str(entry_id))

        project = Project()
        project.get(project_id)
        model = project.get_entry_collection(entry)
        model.delete({"_id": id})
        project.entry_updated()
        return jsonify({"status": True})
开发者ID:sweemeng,项目名称:scrapedump,代码行数:18,代码来源:data.py

示例10: project_view

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import get [as 别名]
def project_view(project_id):
    form = ProjectUpdateForm(csrf_enabled=False)
    project = Project()
    print project_id
    project.get(project_id)
    permission = EditProjectPermission(project_id) 
    edit = False
    if request.method == 'POST':
        edit = True
        if not permission.can():
            abort(403)
        if form.validate_on_submit():
            # name is not edited because it bind to the database name
            project.project.description = form.description.data
            project.save()

    return render_template('project_view.html',project=project,form=form,edit=edit,permission=permission)
开发者ID:sweemeng,项目名称:scrapedump,代码行数:19,代码来源:action.py

示例11: post

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import get [as 别名]
    def post(self, project_id, entry):
        api_key = request.args.get("api_key")

        if not authorized(api_key, project_id):
            return jsonify({"status": False, "message": "user is not authenticated"})

        # Lets disable it for now. Until flask-principal is implemented
        # if project not in user.user.project:
        #    return jsonify({'status':False,'message':'user don nott have access to project'})

        project = Project()
        project.get(project_id)
        model = project.get_entry_collection(entry)

        model.insert(request.json)
        project.entry_updated()
        return jsonify({"status": True})
开发者ID:sweemeng,项目名称:scrapedump,代码行数:19,代码来源:data.py

示例12: project_entry_detail

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import get [as 别名]
def project_entry_detail(project_id,entry_id):
    # add entry should be a new form, remove from old form
    permission = EditProjectPermission(project_id)
    form = EntryUpdateForm(csrf_enabled=False)
    # we also will need upload form FYI
    project = Project()
    project.get(project_id)
    edit = False
    print project.project.entry.keys()
    entry = project.get_entry(entry_id)
    if form.validate_on_submit():
        if not permission.can():
            abort(403)
        description = form.description.data
        source = form.source.data
        project.update_entry(entry_id,description,source)
        edit = True
    # not to mention we will need a project detail
    return render_template('entry_view.html',project=project,form=form,edit=edit,entry_id=entry_id,permission=permission)
开发者ID:sweemeng,项目名称:scrapedump,代码行数:21,代码来源:action.py

示例13: export_worker

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import get [as 别名]
def export_worker(msg):
    project = Project()
    project.get(msg['project_id'])
    completed = project.export_completed(msg['entry_id'],msg['format'])
    file_id = ''
    if completed:
        print 'task completed, making sure file need to regenerated'
        metadata = project.get_exported_file(msg['entry_id'],msg['format'])
        if metadata['file_id']:
            f = project.get_datafile(metadata['file_id'])
            uploaded_date = f.upload_date
            last_updated = project.get_entry_updated()
            print uploaded_date
            print last_updated
            if last_updated > uploaded_date:
                print 'file need regen'
                task = export_single.delay(msg['project_id'],msg['entry_id'],msg['format'])
                print task
                project.set_exporter_task(msg['entry_id'],msg['format'],task.id)
                completed = project.export_completed(msg['entry_id'],msg['format'])
    else:
        task = export_single.delay(msg['project_id'],msg['entry_id'],msg['format'])
        project.set_exporter_task(msg['entry_id'],msg['format'],task.id)
        completed = project.export_completed(msg['entry_id'],msg['format'])
           

    while not completed:
        completed = project.export_completed(msg['entry_id'],msg['format'])
        yield {'completed':False,'file_id':file_id,'format':msg['format'],
               'project_id':msg['project_id'],'entry_id':msg['entry_id']}
        time.sleep(1)
    
    project.get(msg['project_id'])
    metadata = project.get_exported_file(msg['entry_id'],msg['format'])
    print metadata['file_id']
    f = project.get_datafile(metadata['file_id'])
    file_id = metadata['file_id']
    yield {'completed':True,'file_id':file_id,'format':msg['format'],
               'project_id':msg['project_id'],'entry_id':msg['entry_id']}
开发者ID:sweemeng,项目名称:scrapedump,代码行数:41,代码来源:export_worker.py

示例14: loader_task

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import get [as 别名]
def loader_task(project_id,entry,file_id):
    project = Project()
    project.get(project_id)
    project.load_datafile(entry,file_id)
开发者ID:sweemeng,项目名称:scrapedump,代码行数:6,代码来源:data_loader.py

示例15: load_data_upload

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import get [as 别名]
def load_data_upload(project_id,entry_id):
    # This should return json
    # look at jquery-upload
    print "getting upload"
    uploads = request.files.getlist('files[]')
    print "file length: %d" % len(uploads)
    project = Project()
    project.get(project_id)
    # project add_datafile should return file_id
    uploaded_all = []
    # first what if it is a invalid file, 
    # second what if it failed
    for uploaded in uploads:
        print 'filename being uploaded %s' % uploaded.filename
        try:
            file_id = project.add_datafile(entry_id,uploaded)
        except:
            data = {
                'filename':uploaded.filename,
                'name':uploaded.filename.replace('.','_'),
                'content-type':uploaded.content_type,
                'msg':'Invalid File Type, only CSV/Json are supported',
                'success':False
            }
            uploaded_all.append(data)
            continue
        try:
            task_id = loader_task.delay(project_id,entry_id,file_id)
    
            project.set_load_worker(entry_id,file_id,task_id.id)
        except:
            data = {
                'name':uploaded.filename.replace('.','_'),
                'filename':uploaded.filename,
                'content-type':uploaded.content_type,
                'msg':'Problem processing file',
                'success':False,
            }
            uploaded_all.append(data)
            continue

        test_file = project.get_datafile(file_id)

        get_url = '/download/%s/%s/' % (project_id,entry_id)
        delete_url = '/delete/%s/%s/' % (project_id,entry_id)
        data = {
            'success':True,
            'msg':'',
            'file_id':file_id,
            'length':test_file.length,
            'name':test_file.name.replace('.','_'),
            'filename':test_file.name,
            'content-type':test_file.content_type,
            'url':get_url,
            'delete':delete_url
        }
        uploaded_all.append(data)
    
    data = json.dumps(uploaded_all)
    resp = Response(data,status=200,mimetype='application/json')
    resp.headers['Link'] = 'http://localhost:5000'
    return resp
开发者ID:sweemeng,项目名称:scrapedump,代码行数:64,代码来源:action.py


注:本文中的project.model.Project.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。