Exemplo n.º 1
0
def jqueryListOnCollection():
    #Get request param: collectionId, start, cnt
    param = webUtils.paramWithDefault({u"collectionId":u"D:/tmp",u"start":0,u"cnt":100})
    #Get collection from system, collection system contains cached collections and filesystem collections.
    #h.write("<!--")
    #print "hello"
    if not objTools.isUuid(param["collectionId"]):
        #param["collectionId"] = collectionListItems.jsIdEncoding(param["collectionId"])
        param["collectionId"] = stringTools.jsIdDecoding(param["collectionId"])
    #h.write(unicode(str(int(param["start"])))+unicode(str(int(param["cnt"]))))
    co = collectionManager.getCollection(param["collectionId"], dbSys.dbSysSmart())
    containerCo = container.collectionContainer(co, dbSys.dbSysSmart()).getRange(int(param["start"]), int(param["cnt"]))
    #Output
    #h.write(str(co))
    #res = ""
    #h.write("-->")
    if True:#try:
        res = collectionListItem(containerCo)
    else:#except:
        pass
    h = libs.html.response.html()
    #print "hello"
    #h.write("good")
    h.genPartialHtmlHead()
    h.write(res)
    #h.write(l.s)
    #print res
    h.end()
Exemplo n.º 2
0
def jqueryListOnCollection(req):
    #Get request param: collectionId, start, cnt
    param = webUtils.paramWithDefault({u"collectionId":u"C:/",u"start":0,u"cnt":40}, req.getQueryInfo())
    #Get collection from system, collection system contains cached collections and filesystem collections.
    #h.write("<!--")
    #print "hello"
    print param
    if not objTools.isUuid(param["collectionId"]):
        #param["collectionId"] = collectionListItems.jsIdEncoding(param["collectionId"])
        param["collectionId"] = stringTools.jsIdDecoding(param["collectionId"])
    #h.write(unicode(str(int(param["start"])))+unicode(str(int(param["cnt"]))))
    co = collectionManager.getCollection(param["collectionId"], req.getDbSys()).getRange(int(param["start"]), int(param["cnt"]))

    #Output
    #h.write(str(co))
    #res = ""
    #h.write("-->")
    if True:#try:
        resList = collectionListItem(co, req)
    else:#except:
        pass
    #h = libs.html.response.html()
    #print "hello"
    #h.write("good")
    req.resp.genJsonHead()
    req.resp.write(json.dumps(resList, indent = 4))
    #h.write(l.s)
    #print res
    req.resp.end()
Exemplo n.º 3
0
def jqueryListOnCollection(req):
    #Get request param: collectionId, start, cnt
    param = webUtils.paramWithDefault({u"collectionId":u"-1"}, req.getQueryInfo())
    #Get collection from system, collection system contains cached collections and filesystem collections.
    if not objTools.isUuid(param["collectionId"]):
        #It is not uuid://xxxx-xxx-xxx-xxx-xxxx-xxxx
        param["collectionId"] = stringTools.jsIdDecoding(param["collectionId"])
    #Output
    req.resp.genJsonHead()
    if param["collectionId"] == "-1":
        p = ufs.ufsTreeUuidItem()
    #res = path
    else:
        #p = desktopApp.lib.localTreeItem.localTreeItem(path.decode('utf8'))
        if objTools.isUfsUrl(param["collectionId"]):#try:
            p = ufsTreeItem.getUfsTreeItem(param["collectionId"], req)
            #print "after getufstreeitem"
            #res += str(p.listNamedChildren())
        else:#except ValueError:
            #No schema/protocol string. Normal dir
            p = jsTreeItemWithCollectionBackend.jsTreeItemWithCollectionBackend(param["collectionId"], None, req.getDbSys())
    #Get the checked elements in the tree
    try:
        co = collectionManager.getCollection(u"uuid://3b84d155-cc5c-428e-8009-12d5fdc68b2a", req.getDbSys()).getRange(0, None)
    except KeyError:
        co = []
    #print "before containerListJson"
    data = jsTreeNamedItemFunc.containerListJson(p, checkedItems=co)

    #print data
    if data == u"":
        raise "no item, raise exception to prevent loop query"
    req.resp.write(data)
    req.resp.end()
Exemplo n.º 4
0
def jqueryListOnCollection(req):
    #Get request param: collectionId, start, cnt
    param = webUtils.paramWithDefault({u"collectionId":u"-1", u"tree":u"n", u"start":0, u"cnt":40}, req.getQueryInfo())
    #print param

    if param["collectionId"] == "-1":
        ####################################
        # It is the root element of the tree
        ####################################
        collectionItemList = ufs.ufsRootItem()
    elif not objTools.isUuid(param["collectionId"]):
        #############################################
        #It is not uuid://xxxx-xxx-xxx-xxx-xxxx-xxxx
        #############################################
        param["collectionId"] = stringTools.jsIdDecoding(param["collectionId"])
        if not objTools.isUfsUrl(param["collectionId"]):
            param["collectionId"] = u"file:///"+param["collectionId"]
        #Change URL to file:///D:/tmp etc.
        collectionItemList = ufsCollection.getUfsCollection(param["collectionId"], req)
    req.resp.genJsonHead()
    #print collectionItemList.listNamedChildren(0, 40, False)
    ##############################################
    # Get checked item for tree
    ##############################################
    try:
        checkedItemList = collectionManager.getCollection(gCheckedCollectionId, req.getDbSys()).getRange(0, None)
    except KeyError:
        checkedItemList = []
    #print "before containerListJson"
    # Check if we are generating the tree.
    if param["tree"] == u"n":
        #print "false"
        isTree = False
        start = int(param["start"])
        cnt = int(param["cnt"])
    else:
        isTree = True
        start = 0
        cnt = None
    #print start, cnt
    #print >>sys.stderr, "-------------", start, cnt
    #data = "1"
    ####################################################
    # Generate JSON string for collection
    ####################################################
    data = collection2Json.containerListJson(collectionItemList, start, cnt, isTree, req, checkedItemList)
    
    #print data
    if data == u"":
        raise "no item, raise exception to prevent loop query"
    req.resp.write(data)
    req.resp.end()
Exemplo n.º 5
0
    def listNamedChildren(self, start = 0, cnt = None, getParent = True):
        res = {}
        #import sys
        #print >>sys.stderr, "----------------", start, cnt, type(start)
        for i in self.collection.getRange(start, cnt):
            if objTools.isUfsUrl(i):
                i = getUrlContent(i)
            if getParent:
                if collectionManager.getCollection(i, self.dbSys).isEmpty():
                    continue

            res[i] = os.path.basename(i)
        return res
Exemplo n.º 6
0
Arquivo: ufsFs.py Projeto: weijia/ufs
 def listNamedChildren(self, start = 0, cnt = None, getParent = True):
     #Return {fullPath:name}
     db = dbSys.dbSysSmart()
     co = collectionManager.getCollection(u"ufsFs://"+self.id, db).getRange(0, None)
     #res = {getUfsUuidItemUrl(self.id):getUfsUuidItemUrl(self.id)}
     res = {}
     #res["test"] = co
     ns = nameService.nameService(db.getNameServiceDb())
     for i in co:
         n = ns.getName(i)
         if n is None:
             n = i
         res[i] = objTools.getUfsBasename(n)
     return res
Exemplo n.º 7
0
Arquivo: ufsV2.py Projeto: weijia/ufs
 def listNamedChildren(self, start = 0, cnt = None, getParent = True):
     #Return {fullPath:name}
     db = dbSys.dbSysSmart()
     #print "retriving co:", getUfsUuidItemUrl(self.id)
     co = collectionManager.getCollection(getUfsUuidItemUrl(self.id), db).getRange(0, None)
     #res = {getUfsUuidItemUrl(self.id):getUfsUuidItemUrl(self.id)}
     #res = {}
     #print "got co:", co
     res = odict.OrderedDict()
     #res["test"] = co
     #Hard code the freq items
     res[u"freq://root"] = u"Freqently Used"
     #Hard code the tag system
     res[u"tag://,"] = u"Tag System"
     #Hard code the task system
     res[u"tasklist://,"] = u"Task List"
     #Hard code the task system
     res[u"zippedColllectionWithInfo://,"] = u"Zipped Collections"
     #Storage List
     res[u"storage://"] = u"Storages"
     #Add other item in root item
     ns = nameService.nameService(db.getNameServiceDb())
     for i in co:
         n = ns.getName(i)
         if n is None:
             try:
                 #Get url
                 n = objTools.getUrlContent(i)
             except ValueError:
                 n = None
         if n is None:
             #Seems to be a directory path
             try:
                 n = objTools.getUfsBasename(i)
             except:
                 n = None
         if n is None:
             n = i
         res[i] = n
     if localDriverExist():
         res[u"winUfs"+configurationTools.getFsProtocolSeparator()+winUfs.winUfsRootItemUuid] = u"Filesystem"
     return res
Exemplo n.º 8
0
def jqueryListOnCollection(req):
    #Get request param: collectionId, start, cnt
    param = webUtils.paramWithDefault({u"collectionId":u"-1"}, req.getQueryInfo())
    #Get collection from system, collection system contains cached collections and filesystem collections.
    if not objTools.isUuid(param["collectionId"]):
        #It is not uuid://xxxx-xxx-xxx-xxx-xxxx-xxxx
        param["collectionId"] = stringTools.jsIdDecoding(param["collectionId"])
    #Output
    if gDebugFlag:
        h = libs.html.response.html()
        h.genHead('Collections')
    res = u""
    res += u'<!--'
    if param["collectionId"] == "-1":
        p = ufs.ufsTreeUuidItem()
    #res = path
    else:
        #p = desktopApp.lib.localTreeItem.localTreeItem(path.decode('utf8'))
        if objTools.isUfsUrl(param["collectionId"]):#try:
            #h.write(realUrl)
            h.setEncoding("utf8")
            p = ufsTreeItem.getUfsTreeItem(param["collectionId"], req)
            #res += str(p.listNamedChildren())
        else:#except ValueError:
            #No schema/protocol string. Normal dir
            p = jsTreeItemWithCollectionBackend.jsTreeItemWithCollectionBackend(param["collectionId"], None, req.getDbSys())
    #Get the checked elements in the tree
    try:
        co = collectionManager.getCollection(u"uuid://3b84d155-cc5c-428e-8009-12d5fdc68b2a", req.getDbSys()).getRange(0, None)
    except KeyError:
        co = []
    data = jsTreeNamedItemFunc.containerList(p, checkedItems=co)
    res +=u'-->'
    #print res,d
    if data == u"":
        raise "no item, raise exception to prevent loop query"
    res += data
    if gDebugFlag:
        h.write(res)
        h.genEnd()
    else:
        print res.encode('gbk')
Exemplo n.º 9
0
 def __init__(self, collectionId, parentId, dbSys):
     self.collectionId = collectionId
     self.dbSys = dbSys
     self.parentId = parentId
     self.collection = collectionManager.getCollection(collectionId, dbSys)