V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  xpke04  ›  全部回复第 1 页 / 共 1 页
回复总数  6
2018-04-09 16:30:06 +08:00
回复了 xpke04 创建的主题 Python 请教针对不同 Model 对象的相似处理的精简方法?
v2ex 贴代码太不方便了,我把问题移至 segmentfault 了, https://segmentfault.com/q/1010000014261968
2018-04-09 16:21:22 +08:00
回复了 xpke04 创建的主题 Python 请教针对不同 Model 对象的相似处理的精简方法?
补充一下描述,

``` python
def change_docorder():
reqdata = request.json
op = reqdata["op"]
docid = reqdata["docid"]

# 如果是上移文档顺序
if op == "up":
another = DocItem.query.filter(and_(DocItem.category_id == docitem.category_id,
DocItem.order < docitem.order)).order_by(DocItem.order.desc()).first()
if another is None:
return error_response(u"无法继续移动该文档顺序!")
tmp = another.order
another.order = docitem.order
docitem.order = tmp
another.save()
docitem.save()
elif op == "down":
another = DocItem.query.filter(and_(DocItem.category_id == docitem.category_id,
DocItem.order>docitem.order)).order_by(DocItem.order.asc()).first()
if another is None:
return error_response(u"无法继续移动该文档顺序!")
tmp = another.order
another.order = docitem.order
docitem.order = tmp
another.save()
docitem.save()
else:
return make_response(u"非法的操作!")
return make_response(json.dumps({
"status": "success",
"msg": u"修改文档顺序成功!"
}))
```

这是针对 DocItem 这个 model 进行的调整顺序操作,还有其他的几个 model 对象需要进行相同的操作,如何如果都分别写一个函数来实现功能,最终代码只有类名 `DocItem` 是不一样的。

以上是对问题的补充描述。
2017-10-27 15:01:13 +08:00
回复了 xpke04 创建的主题 问与答 docker 中多个容器访问 expose 端口的诡异问题
补充,docker 网络使用的是默认的 bridge 模式,另外,在容器中是能够访问主机上绑定的其他端口的服务的,但是不能访问容器 expose 出来的端口上的服务。
2016-02-24 13:40:15 +08:00
回复了 xpke04 创建的主题 酷工作 网易游戏的 BI 岗位主要工作内容和能力要求
给自己挽尊。
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3545 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 21ms · UTC 00:10 · PVG 08:10 · LAX 17:10 · JFK 20:10
Developed with CodeLauncher
♥ Do have faith in what you're doing.