Coder Social home page Coder Social logo

Comments (2)

Ma233 avatar Ma233 commented on June 2, 2024

object_id 在云存储中不存在的时候,会返回一个本地构造的 object,可以通过 created_at 是否被设置来察觉到。
当前我们自己的项目里做了这样的 patch:

from leancloud import Query as OriginalQuery


class Query(OriginalQuery):
    def get(self, object_id):
        obj = super().get(object_id)

        # 此处也可以 raise 101,大家可以按自己的习惯来
        return obj if getattr(obj, "created_at", None) else None


def patch_leancloud():
    import leancloud

    leancloud.Query = Query

from python-sdk.

weakish avatar weakish commented on June 2, 2024

可以通过 crerated_at 是否被设置来察觉到

是的,其实 SDK 提供了一个 is_existed 方法(这个方法在实现上也是检查 created_at

from python-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.