本文整理汇总了Python中mediacrush.objects.RedisObject类的典型用法代码示例。如果您正苦于以下问题:Python RedisObject类的具体用法?Python RedisObject怎么用?Python RedisObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RedisObject类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: frame
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)
开发者ID:JIVS,项目名称:MediaCrush,代码行数:26,代码来源:media.py
示例2: hash_text
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'}
开发者ID:mpmedia,项目名称:MediaCrush,代码行数:31,代码来源:api.py
示例3: get
def get(self, id):
klass = RedisObject.klass(id)
if not klass:
return {'error': 404}, 404
o = klass.from_hash(id)
return objects[klass](o)
开发者ID:mpmedia,项目名称:MediaCrush,代码行数:8,代码来源:api.py
示例4: fragment
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)
开发者ID:FoleyDiver,项目名称:MediaCrush,代码行数:9,代码来源:media.py
示例5: status
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))
开发者ID:FoleyDiver,项目名称:MediaCrush,代码行数:11,代码来源:media.py
示例6: delete
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'}
开发者ID:mpmedia,项目名称:MediaCrush,代码行数:14,代码来源:api.py
示例7: info
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
开发者ID:mpmedia,项目名称:MediaCrush,代码行数:15,代码来源:api.py
示例8: album_zip
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"}
开发者ID:mpmedia,项目名称:MediaCrush,代码行数:15,代码来源:api.py
示例9: get
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))
开发者ID:Thapelo-Tsotetsi,项目名称:MediaCrush,代码行数:16,代码来源:media.py
示例10: status
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
开发者ID:Web5design,项目名称:MediaCrush,代码行数:16,代码来源:api.py
示例11: direct
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)
开发者ID:Thapelo-Tsotetsi,项目名称:MediaCrush,代码行数:17,代码来源:media.py
示例12: status_bulk
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
开发者ID:mpmedia,项目名称:MediaCrush,代码行数:17,代码来源:api.py
示例13: get
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))
开发者ID:Artanis44,项目名称:MediaCrush,代码行数:19,代码来源:media.py
示例14: album
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}
开发者ID:Web5design,项目名称:MediaCrush,代码行数:19,代码来源:api.py
示例15: status
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
开发者ID:mpmedia,项目名称:MediaCrush,代码行数:20,代码来源:api.py
示例16: direct
def direct(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)
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)
开发者ID:FoleyDiver,项目名称:MediaCrush,代码行数:20,代码来源:media.py
示例17: frame
def frame(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)
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)
开发者ID:FoleyDiver,项目名称:MediaCrush,代码行数:20,代码来源:media.py
示例18: get
def get(self, id, layout):
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)
if not f.processor:
# TODO: Better error page
return render_template("error.html", error="Unable to detect file type")
return render_template("view.html", **_template_params(f))
开发者ID:nerdzeu,项目名称:NERDZCrush,代码行数:20,代码来源:media.py
示例19: flags_post
def flags_post(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
# At this point, we're authenticated and o is the object.
for flag, value in request.form.items():
v = True if value == 'true' else False
try:
setattr(o.flags, flag, v)
except AttributeError:
return {'error': 415}, 415
o.save()
return {"flags": o.flags.as_dict()}
开发者ID:mpmedia,项目名称:MediaCrush,代码行数:24,代码来源:api.py
注:本文中的mediacrush.objects.RedisObject类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论