本文整理汇总了Python中models.File.put方法的典型用法代码示例。如果您正苦于以下问题:Python File.put方法的具体用法?Python File.put怎么用?Python File.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.File
的用法示例。
在下文中一共展示了File.put方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import File [as 别名]
# 或者: from models.File import put [as 别名]
def post(self):
item = None
vals = {}
# get all the incoming values
title = self.request.get('title').strip()
blob_key = None
label_raw = self.request.get('label_raw').strip()
# get the file information
uploaded_files = self.get_uploads('file')
if len(uploaded_files) == 1:
blob_info = uploaded_files[0]
blob_key = blob_info.key()
if self.request.get('key'):
item = File.get( self.request.get('key') )
item.title = title
item.label_raw = label_raw
else:
item = File(
title = title,
label_raw = label_raw,
)
if blob_key:
item.blob = blob_key
# update and save this file
item.set_derivatives()
item.put()
self.redirect('.')
示例2: GetOutput
# 需要导入模块: from models import File [as 别名]
# 或者: from models.File import put [as 别名]
def GetOutput(self):
# if not self.check_user():
# return
file_id = self.request.get("id")
file = self.get_file(file_id)
if file is None:
file = File()
file.put()
else:
if self.get_file_permission(file) < base.ACCESS_READ:
self.redirect('/')
return
head = file.head
if head is None:
file_text = "Welcome to ZenTxt!"
revisions = []
else:
#file_text = cgi.escape(head.content)
file_text = head.content
revisions = self.get_revisions(file)
template_values = {
'user' : self.get_current_user(),
'file_id' : file_id,
'revisions' : revisions,
'file_text' : file_text,
'login_url' : users.create_login_url(self.request.uri)
}
path = self.get_template_path( 'file.html' )
return template.render(path, template_values)
示例3: post
# 需要导入模块: from models import File [as 别名]
# 或者: from models.File import put [as 别名]
def post(self):
fil = self.request.POST["file"]
if not fil.value:
self.redirect("/")
return
logging.getLogger().info("selected val %s" % self.request.POST["compression-type"])
if self.request.POST["compression-type"] == "NONE":
data = fil.value
else:
params = urllib.urlencode(
[
("js_code", fil.value),
("compilation_level", self.request.POST["compression-type"]),
("output_format", "text"),
("output_info", "compiled_code"),
]
)
headers = {"Content-type": "application/x-www-form-urlencoded"}
conn = httplib.HTTPConnection("closure-compiler.appspot.com")
conn.request("POST", "/compile", params, headers)
response = conn.getresponse()
data = response.read()
conn.close
file = File()
file.name = fil.filename
file.file = db.Blob(data)
file.content_type = fil.type
file.user = users.get_current_user()
file.put()
self.redirect("/")
示例4: put
# 需要导入模块: from models import File [as 别名]
# 或者: from models.File import put [as 别名]
def put(self, filename):
file_uuid = uuid4().hex
file = File(name=str(urllib.unquote(filename)),
content_type=self.request.headers.get('Content-Type', None),
key_name=file_uuid)
file.put()
for chunk in chunks(self.request.body, config.max_fragment_size):
Fragment(file=file, data=chunk).put()
self.response.set_status(201)
self.response.out.write(file_uuid)
示例5: create_file
# 需要导入模块: from models import File [as 别名]
# 或者: from models.File import put [as 别名]
def create_file(self, filename, user=None):
file = File()
if user is None:
user = self.get_current_user()
file.author = user
file.name = filename
key = file.put()
self.create_permission(file, file.author, ACCESS_WRITE)
#self.redirect('/file?' + urllib.urlencode({'id': key}))
return key