22from ide import app , models , routes , modDBFunctions
33from google .cloud import ndb
44
5-
65@app .shell_context_processor
76def make_shell_context ():
87 """
9- In the flask shell use the `wc` function to call ndb methods like so:
8+ In the flask shell use the `wc` decorator to call ndb methods like so:
9+
10+ @wc
11+ def doSomething(foo, bar):
12+ modDBFunctions.DumpUsers(User=foo, Bar=bar)
1013
11- `wc(modDBFunction.DumpUsers, User=User)`
14+ doSomething()
1215
1316 This will create an ndb context and then invoke the requested function with kwargs provided.
1417
@@ -18,12 +21,12 @@ def make_shell_context():
1821
1922 client = ndb .Client (project = project ) # for user data, folders, and programs
2023
21- def wc (func , ** args ):
22- with client .context ():
23- func (** args )
24-
25- return {'app' : app , 'User' : models .User , 'Folder' :models .Folder , 'Program' :models .Program , 'Setting' :models .Setting ,
26- 'ndb' :ndb , 'wc' :wc , 'models' :models , 'routes' :routes ,
27- 'project' :project , 'client' :client , 'modDBFunctions' :modDBFunctions }
24+ import fs_utils as fsu
2825
26+ def doLoadPrograms (path ):
27+ loader = fsu .buildLoader (client , models .Program , ndb , 'localuser' , 'testupdate' , modDBFunctions )
28+ fsu .LoadProgramVisitor (path , loader )
2929
30+ return {'app' : app , 'User' : models .User , 'Folder' :models .Folder , 'Program' :models .Program ,
31+ 'Setting' :models .Setting ,'ndb' :ndb , 'models' :models , 'routes' :routes , 'project' :project ,
32+ 'client' :client , 'modDBFunctions' :modDBFunctions , 'doLoadPrograms' :doLoadPrograms }
0 commit comments