本文整理汇总了Python中mediacrush.objects.RedisObject.klass方法的典型用法代码示例。如果您正苦于以下问题:Python RedisObject.klass方法的具体用法?Python RedisObject.klass怎么用?Python RedisObject.klass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mediacrush.objects.RedisObject
的用法示例。
在下文中一共展示了RedisObject.klass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: frame
# 需要导入模块: from mediacrush.objects import RedisObject [as 别名]
# 或者: from mediacrush.objects.RedisObject import klass [as 别名]
def frame(self, id):
send = self._send_file(id)
if send:
return send
# We only want to maintain one page for mobile, not a dozen
if (
request.user_agent.platform in ["android", "iphone", "ipad"]
or "windows phone" in request.user_agent.string.lower()
):
return redirect("/" + id, code=302)
klass = RedisObject.klass(id)
if klass is Album:
album = klass.from_hash(id)
v = _album_params(album)
v["embedded"] = True
v["filename"] = id
return render_template("album-embedded.html", **v)
if klass is not File:
abort(404)
f = File.from_hash(id)
template_params = _template_params(f)
template_params["embedded"] = True
return render_template("direct.html", **template_params)
示例2: hash_text
# 需要导入模块: from mediacrush.objects import RedisObject [as 别名]
# 或者: from mediacrush.objects.RedisObject import klass [as 别名]
def hash_text(self, h):
klass = RedisObject.klass(h)
max_length = 2048
if not klass or klass not in [Album, File]:
return {'error': 404}, 404
properties = ["title", "description"]
if not any(prop in request.form for prop in properties):
return {'error': 400}, 400
try:
o = klass.from_hash(h) # We don't care about the object type
if not check_password_hash(o.ip, get_ip()):
return {'error': 401}, 401
except:
return {'error': 401}, 401
if o.text_locked:
return {'error': 408}, 408
for prop in properties:
if prop in request.form:
data = request.form[prop]
if len(data) > max_length:
return {'error': 414}, 414
setattr(o, prop, data)
o.save()
return {'status': 'success'}
示例3: get
# 需要导入模块: from mediacrush.objects import RedisObject [as 别名]
# 或者: from mediacrush.objects.RedisObject import klass [as 别名]
def get(self, id):
klass = RedisObject.klass(id)
if not klass:
return {'error': 404}, 404
o = klass.from_hash(id)
return objects[klass](o)
示例4: fragment
# 需要导入模块: from mediacrush.objects import RedisObject [as 别名]
# 或者: from mediacrush.objects.RedisObject import klass [as 别名]
def fragment(self, id):
klass = RedisObject.klass(id)
if klass is not File:
abort(404)
f = File.from_hash(id)
params = _template_params(f)
params['album'] = True
return render_template(params['fragment'], **params)
示例5: status
# 需要导入模块: from mediacrush.objects import RedisObject [as 别名]
# 或者: from mediacrush.objects.RedisObject import klass [as 别名]
def status(self, id):
klass = RedisObject.klass(id)
if klass is not File:
abort(404)
f = File.from_hash(id)
template_params = _template_params(f)
if f.status in ['done', 'ready']:
return tor_redirect('/' + f.hash)
return render_template("status.html", **_template_params(f))
示例6: delete
# 需要导入模块: from mediacrush.objects import RedisObject [as 别名]
# 或者: from mediacrush.objects.RedisObject import klass [as 别名]
def delete(self, h):
klass = RedisObject.klass(h)
if not klass:
return {'error': 404}, 404
try:
o = klass.from_hash(h)
if not check_password_hash(o.ip, get_ip()):
return {'error': 401}, 401
except:
return {'error': 401}, 401
deletion_procedures[klass](o)
return {'status': 'success'}
示例7: info
# 需要导入模块: from mediacrush.objects import RedisObject [as 别名]
# 或者: from mediacrush.objects.RedisObject import klass [as 别名]
def info(self):
if not "list" in request.args:
return {'error': 400}, 400
items = request.args['list'].split(',')
res = {}
for i in items:
klass = RedisObject.klass(i)
if not klass or klass not in objects:
res[i] = None
else:
o = klass.from_hash(i)
res[i] = objects[klass](o)
return res
示例8: album_zip
# 需要导入模块: from mediacrush.objects import RedisObject [as 别名]
# 或者: from mediacrush.objects.RedisObject import klass [as 别名]
def album_zip(self):
if "hash" not in request.form:
return {"error": 415}, 415
h = request.form["hash"]
klass = RedisObject.klass(h)
if not klass or klass is not Album:
return {"error": 404}, 404
if os.path.exists(file_storage(h) + ".zip"):
return {"status": "done"}
zip_album.delay(h)
return {"status": "success"}
示例9: get
# 需要导入模块: from mediacrush.objects import RedisObject [as 别名]
# 或者: from mediacrush.objects.RedisObject import klass [as 别名]
def get(self, id, layout):
send = self._send_file(id)
if send:
return send
klass = RedisObject.klass(id)
if klass is Album:
album = klass.from_hash(id)
v = _album_params(album)
return render_template("albums/%s.html" % layout, **v)
if klass is not File:
abort(404)
f = File.from_hash(id)
return render_template("view.html", **_template_params(f))
示例10: status
# 需要导入模块: from mediacrush.objects import RedisObject [as 别名]
# 或者: from mediacrush.objects.RedisObject import klass [as 别名]
def status(self, h):
klass = RedisObject.klass(h)
if not klass:
return {'error': 404}, 404
if klass is not File:
return {'error': 415}, 415
f = File.from_hash(h)
ret = {'status': f.status}
if ret['status'] == 'done':
ret[h] = _file_object(f)
ret['hash'] = h
return ret
示例11: direct
# 需要导入模块: from mediacrush.objects import RedisObject [as 别名]
# 或者: from mediacrush.objects.RedisObject import klass [as 别名]
def direct(self, id):
send = self._send_file(id)
if send:
return send
klass = RedisObject.klass(id)
if klass is Album:
album = klass.from_hash(id)
v = _album_params(album)
return render_template("album.html", **v)
if klass is not File:
abort(404)
f = File.from_hash(id)
template_params = _template_params(f)
return render_template("direct.html", **template_params)
示例12: status_bulk
# 需要导入模块: from mediacrush.objects import RedisObject [as 别名]
# 或者: from mediacrush.objects.RedisObject import klass [as 别名]
def status_bulk(self):
if not "list" in request.args:
return {'error': 400}, 400
items = request.args['list'].split(',')
res = {}
for i in items:
klass = RedisObject.klass(i)
if not klass:
res[i] = None
else:
o = klass.from_hash(i)
res[i] = {'status': o.status}
if klass is not FailedFile:
res[i]['file'] = _file_object(o)
return res
示例13: get
# 需要导入模块: from mediacrush.objects import RedisObject [as 别名]
# 或者: from mediacrush.objects.RedisObject import klass [as 别名]
def get(self, id, layout):
send = self._send_file(id)
if send:
return send
klass = RedisObject.klass(id)
if klass is Album:
album = klass.from_hash(id)
v = _album_params(album)
v['layout'] = layout
if layout == "random":
random.shuffle(v['items']) # It's in-place
return render_template("albums/%s.html" % layout, **v)
if klass is not File:
abort(404)
f = File.from_hash(id)
return render_template("view.html", **_template_params(f))
示例14: album
# 需要导入模块: from mediacrush.objects import RedisObject [as 别名]
# 或者: from mediacrush.objects.RedisObject import klass [as 别名]
def album(self):
items = request.form['list'].split(",")
for i in items:
klass = RedisObject.klass(i)
if not klass: # Does not exist
return {'error': 404}, 404
if klass != File: # Wrong type
return {'error': 415}, 415
if len(items) > 50:
return {'error': 413}, 413
a = Album()
a.items = items
a.ip = secure_ip()
a.save()
return {"hash": a.hash}
示例15: status
# 需要导入模块: from mediacrush.objects import RedisObject [as 别名]
# 或者: from mediacrush.objects.RedisObject import klass [as 别名]
def status(self, h):
klass = RedisObject.klass(h)
if not klass:
return {'error': 404}, 404
if klass is FailedFile:
ff = klass.from_hash(h)
return {'status': ff.status}
if klass is not File:
return {'error': 415}, 415
f = File.from_hash(h)
ret = {'status': f.status}
if f.processor is not None: # When processor is available, ther rest of the information is too, even if the file might not have finished processing yet.
ret[h] = _file_object(f)
ret['hash'] = h
return ret