Data Modelling Advice for Blog Tagging system on Google App Engine

前端 未结 4 913
别跟我提以往
别跟我提以往 2020-12-24 00:01

Am wondering if anyone might provide some conceptual advice on an efficient way to build a data model to accomplish the simple system described below. Am somewhat new to th

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-24 00:25

    One possible way is with Expando, where you'd add a tag like:

    setattr(entity, 'tag_'+tag_name, True)
    

    Then you could query all the entities with a tag like:

    def get_all_with_tag(model_class, tag):
        return model_class.all().filter('tag_%s =' % tag, True)
    

    Of course you have to clean up your tags to be proper Python identifiers. I haven't tried this, so I'm not sure if it's really a good solution.

提交回复
热议问题