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


Python File.put方法代码示例

本文整理汇总了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('.')
开发者ID:ranginui,项目名称:kohacon,代码行数:34,代码来源:file.py

示例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)
开发者ID:sqba,项目名称:zentxt,代码行数:35,代码来源:file.py

示例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("/")
开发者ID:jakobholmelund,项目名称:appengine-image-host,代码行数:36,代码来源:backend.py

示例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)
开发者ID:protomouse,项目名称:appengine-filestore,代码行数:15,代码来源:handlers.py

示例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
开发者ID:sqba,项目名称:zentxt,代码行数:12,代码来源:base.py


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