示例#1
0
文件: insert.py 项目: bfeng/dfs
    def post(self):
        key = self.request.get("key")
        value = self.request.get("value")

        filename = urllib.unquote(key)

        # Clean up current file
        query = DataFile.all().filter("f_key", filename)

        for data_file in query:
            data_file.delete()

        # Create a file
        writable_file_name = files.blobstore.create(mime_type="application/octect-stream")

        with files.open(writable_file_name, "a") as f:
            f.write(value)
        files.finalize(writable_file_name)

        blob_key = files.blobstore.get_blob_key(writable_file_name)

        data_file = DataFile(f_key=filename, f_value=blob_key)
        data_file.put()

        if memcache.get(key="turn") == "on":
            if BlobInfo.get(blob_key).size <= 100000:
                memcache.set(key=filename, value=value, time=3600)

        write_boolean(self, True)
示例#2
0
文件: check.py 项目: bfeng/dfs
    def post(self):
        key = urllib.unquote(self.request.get("key"))

        query = DataFile.gql("WHERE f_key = :1", key)
        if query.count() >= 1:
            write_boolean(self, True)
        else:
            write_boolean(self, False)
示例#3
0
文件: remove.py 项目: bfeng/dfs
  def post(self):
    key = urllib.unquote(self.request.get('key'))

    query = DataFile.all().filter('f_key =', key)
    data_file = query.get()
    if data_file is None:
      write_boolean(self, False)
    else:
      if data_file.f_value:
          data_file.f_value.delete()
      data_file.delete()
      write_boolean(self, True)
示例#4
0
文件: find.py 项目: bfeng/dfs
  def post(self):
    key = urllib.unquote(self.request.get('key'))

    if memcache.get(key="turn") == 'on':
      data = memcache.get(key)
      if data is not None:
        write_string(self, data)
        return

    query = DataFile.all().filter('f_key =', key)

    data_file = query.get()

    if data_file:
      blob_reader = blobstore.BlobReader(data_file.f_value, buffer_size=1048576)
      for line in blob_reader:
        write_string(self, line)
    else:
      write_boolean(self, False)
示例#5
0
文件: memcache.py 项目: bfeng/dfs
  def post(self):
    turn = self.request.get('turn')

    if turn is not None:
      if turn == 'on' or turn == 'off':
        memcache.set(key="turn", value=turn, time=3600)
        write_boolean(self, True)
      else:
        write_boolean(self, False)
    else:
      write_boolean(self, False)
示例#6
0
文件: main.py 项目: bfeng/dfs
 def get(self):
   write_boolean(self, True)