Skip to content
This repository was archived by the owner on Sep 29, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions prototypes/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from server.prototypes import BasicApplication
from server.bones import baseBone, keyBone, numericBone
from server.skeleton import Skeleton, skeletonByKind
from server.skeleton import Skeleton, SkelList, skeletonByKind
from server.tasks import callDeferred

from datetime import datetime
Expand Down Expand Up @@ -146,10 +146,11 @@ def fixTxn( nodeKey, newRepoKey ):

## Internal exposed functions

@exposed
@internalExposed
def pathToKey( self, key ):
def pathToKey(self, key, *args, **kwargs):
"""
Returns the recursively expanded path through the Tree from the root-node to the given *key*.
Returns the recursively expanded path through the Tree from the root-node to te given *key*.

:param key: URL-safe key of the destination node.
:type key: str
Expand All @@ -158,29 +159,32 @@ def pathToKey( self, key ):
given node key.
:rtype: dict
"""
nodeSkel = self.viewNodeSkel()
skel = self.viewNodeSkel()

if not nodeSkel.fromDB( key ):
if not skel.fromDB(key):
raise errors.NotFound()

if not self.canList( "node", key ):
if not self.canList("node", key):
raise errors.Unauthorized()

res = [ self.render.collectSkelData( nodeSkel ) ]
res = SkelList(skel)
res.append(skel.getValuesCache())

for x in range(0,99):
if not nodeSkel["parentdir"]:
for x in range(0, 99):
if not skel["parentdir"]:
break

parentdir = nodeSkel["parentdir"]

nodeSkel = self.viewNodeSkel()
if not nodeSkel.fromDB( parentdir ):
parentdir = skel["parentdir"]
skel = self.viewNodeSkel()
if not skel.fromDB(parentdir):
break

res.append( self.render.collectSkelData( nodeSkel ) )
if not self.canView("node", skel):
continue

res.insert(0, skel.getValuesCache())

return( res[ : : -1 ] )
return self.render.list(res)

def ensureOwnUserRootNode( self ):
"""
Expand Down
1 change: 0 additions & 1 deletion render/html/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ def collectSkelData(self, skel):
:returns: A dictionary or list of dictionaries.
:rtype: dict | list
"""
#logging.error("collectSkelData %s", skel)
if isinstance(skel, list):
return [self.collectSkelData(x) for x in skel]
res = {}
Expand Down
4 changes: 2 additions & 2 deletions render/json/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,10 @@ def list(self, skellist, action = "list", params=None, **kwargs):

def editItemSuccess(self, skel, params=None, **kwargs):
return self.renderEntry(skel, "editSuccess", params)

def addItemSuccess(self, skel, params=None, **kwargs):
return self.renderEntry(skel, "addSuccess", params)

def addDirSuccess(self, rootNode, path, dirname, params=None, *args, **kwargs):
return json.dumps("OKAY")

Expand Down