xpke04 最近的时间轴更新
xpke04

xpke04

V2EX 第 160255 号会员,加入于 2016-02-24 10:27:59 +08:00
请教针对不同 Model 对象的相似处理的精简方法?
Python  •  xpke04  •  2018-04-09 16:30:06 PM  •  最后回复来自 xpke04
4
Nginx 反向代理到 https 出现 502
问与答  •  xpke04  •  2017-12-06 19:57:21 PM  •  最后回复来自 amrnxcdt
2
docker 中多个容器访问 expose 端口的诡异问题
问与答  •  xpke04  •  2017-10-27 15:01:13 PM  •  最后回复来自 xpke04
1
网易游戏的 BI 岗位主要工作内容和能力要求
  •  1   
    酷工作  •  xpke04  •  2016-02-24 13:40:15 PM  •  最后回复来自 xpke04
    1
    xpke04 最近回复了
    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   ·   我们的愿景   ·   实用小工具   ·   3225 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 13:54 · PVG 21:54 · LAX 06:54 · JFK 09:54
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.