Last active
February 25, 2021 12:01
-
-
Save silenius/a0ef358227a655b187b1708b8fc7cdb4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@view_config(request_method='GET', renderer='string', | |
name='hierarchy', accept='application/json') | |
def hierarchy(self): | |
from amnesia.modules.folder import Folder | |
from amnesia.modules.folder.services import get_children | |
from amnesia.modules.folder.validation import FolderSchema | |
from pyramid.renderers import JSON | |
from pyramid.response import Response | |
schema = FolderSchema(only=('id', 'title')) | |
json = JSON() | |
json.add_adapter(Folder, lambda obj, req: schema.dump(obj)) | |
result = get_children( | |
self.request.dbsession, | |
self.context.entity.id | |
) | |
return json(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment