Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

可否提供 load 方法,用于载入 dump 方法导出的数据,以便于用户缓存数据 #492

Copy link
Copy link

Description

@Ma233
Issue body actions

无法直接通过 __init__ 方法还原一个 dump 出来的数据,所以自己做了一个:

class Object:
    @classmethod
    def load(cls, attrs):
        obj, meta_date = cls(), dict()

        for k in ("createdAt", "updatedAt"):
            v = attrs.pop(k, None)
            if v is not None:
                meta_date[k] = v
                obj._attributes[k] = utils.decode(k, v)

        obj._merge_metadata(meta_date)

        # 此处不能直接 obj.set(attrs),否则 Pointer 类型会被当做字典设置到字段上
        for k, v in attrs.items():
            obj.set(k, v)

        return obj
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.