本文整理汇总了Python中project.model.Project类的典型用法代码示例。如果您正苦于以下问题:Python Project类的具体用法?Python Project怎么用?Python Project使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Project类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_project_update
def test_project_update():
project = Project()
project.find('test project update')
project.project.description = 'project updated'
project.save()
db = MongoModel(project='internal',collection='project')
temp = db.query({'name':'test project update'})
assert temp['description'] == 'project updated'
示例2: setup_user_project
def setup_user_project():
# now create user
user = User()
user.create('test_user_update_project','test_pass','[email protected]')
# create project
project = Project()
project.create('project update','project update content')
# associate project
user.add_project(project.get_id())
示例3: setup_project
def setup_project():
data = (
('project 1','project content 1'),
('project 2','project content 2'),
('project 3','project content 3')
)
for d in data:
project = Project()
project.create(d[0],d[1])
示例4: test_get_all
def test_get_all():
project = Project()
project.find('scraped')
entry_id = project.find_entry('entry')
client = webapp.app.test_client()
response = client.get('/api/db/%s/%s/' % (project.project.id,entry_id))
result = json.loads(response.data)
assert result[0]['a'] == 1
示例5: test_project_stats
def test_project_stats():
project = Project()
project.find('test project db')
entry_id = project.find_entry('test entries')
print entry_id
print project.project.entry
databases = project.get_stats()
for database in databases:
assert database == entry_id
示例6: teardown_project_delete
def teardown_project_delete():
user = User()
user.login('test_user_delete_api_project','test_pass')
project = Project()
model = MongoModel(project=user.project,collection=user.collection)
model.delete({'_id':ObjectId(user.user.id)})
project.find('project 1')
model = MongoModel(project=project.project_,collection=project.collection_)
model.delete({'name':'project 1'})
model.conn.drop_database('project_1')
示例7: test_project_view
def test_project_view():
test_client = webapp.app.test_client()
result = test_client.get('/')
project = Project()
project.find('project view')
assert project.project.id in result.data
result = test_client.get('/project/%s/'% project.project.id)
assert 'project view' in result.data
assert 'data' in result.data
示例8: teardown_test_load_data
def teardown_test_load_data():
project = Project()
project.find('test load data')
fs = gridfs.GridFS(project.get_db())
for entry in project.project.input_file:
for file_id in project.project.input_file[entry]:
fs.delete(ObjectId(file_id))
db = MongoModel(project='internal',collection='project')
db.delete({'name':'test load data'})
db.conn.drop_database('test_load_data')
示例9: export_single
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)
示例10: delete_data_upload
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])
示例11: get_data_upload
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
示例12: download_export
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
示例13: teardown_project
def teardown_project():
data = (
('project 1','project content 1'),
('project 2','project content 2'),
('project 3','project content 3')
)
for d in data:
project = Project()
project.find(d[0])
model = MongoModel(project=project.project_,collection=project.collection_)
model.delete({'_id':ObjectId(str(project.project.id))})
model.conn.drop_database(d[0].replace(' ','_'))
示例14: add_entry
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)
示例15: test_project_entries
def test_project_entries():
project = Project()
project.find('test project entries')
# add_entries now should have a description and name file
# there should be a short name field, for field name
# We should have a source
entry_id = project.add_entry('test entries','test data','test_entries','test_entries')
db = MongoModel(project='internal',collection='project')
temp = db.query({'name':'test project entries'})
assert entry_id in temp['stats']