xpke04's recent timeline updates
xpke04

xpke04

V2EX member #160255, joined on 2016-02-24 10:27:59 +08:00
xpke04's recent replies
v2ex 贴代码太不方便了,我把问题移至 segmentfault 了, https://segmentfault.com/q/1010000014261968
补充一下描述,

``` 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` 是不一样的。

以上是对问题的补充描述。
补充,docker 网络使用的是默认的 bridge 模式,另外,在容器中是能够访问主机上绑定的其他端口的服务的,但是不能访问容器 expose 出来的端口上的服务。
给自己挽尊。
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4264 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 21ms · UTC 05:21 · PVG 13:21 · LAX 22:21 · JFK 01:21
♥ Do have faith in what you're doing.