Browse Source

add some annotations + clean code

Damien Accorsi 11 years ago
parent
commit
ace90b3e62
1 changed files with 14 additions and 21 deletions
  1. 14 21
      pboard/pboard/lib/dbapi.py

+ 14 - 21
pboard/pboard/lib/dbapi.py View File

109
     return loNewNode
109
     return loNewNode
110
 
110
 
111
 
111
 
112
-  def getNode(self, liNodeId):
113
-    """
114
-    liOwnerIdList = self._getUserIdListForFiltering()
115
-    if liNodeId!=0:
116
-      return DBSession.query(pbmd.PBNode).options(joinedload_all("_lAllChildren")).filter(pbmd.PBNode.node_id==liNodeId).filter(pbmd.PBNode.owner_id.in_(liOwnerIdList)).one()
117
-    return None
118
-    """
112
+  def getNode(self, liNodeId: int) -> pbmd.PBNode:
119
 
113
 
120
-    sqla.or_
121
     lsSqlSelectQuery = """pod_nodes.node_id IN
114
     lsSqlSelectQuery = """pod_nodes.node_id IN
122
-(SELECT
123
-	pgn.node_id
124
-FROM
125
-	pod_group_node AS pgn
126
-	join pod_user_group AS pug ON pug.group_id = pgn.group_id
127
-	join pod_user AS pu ON pug.user_id = pu.user_id
128
-WHERE
129
-	rights > 0
130
-	AND pu.user_id = %s)
131
-"""
115
+        (SELECT
116
+            pgn.node_id
117
+        FROM
118
+            pod_group_node AS pgn
119
+            join pod_user_group AS pug ON pug.group_id = pgn.group_id
120
+            join pod_user AS pu ON pug.user_id = pu.user_id
121
+        WHERE
122
+            rights > 0
123
+            AND pu.user_id = %s)
124
+    """
132
     lsNodeIdFiltering = lsSqlSelectQuery % (str(self._iCurrentUserId))
125
     lsNodeIdFiltering = lsSqlSelectQuery % (str(self._iCurrentUserId))
133
-    print("filter: ====>>>", lsNodeIdFiltering)
126
+
134
     if liNodeId!=0:
127
     if liNodeId!=0:
135
       return DBSession.query(pbmd.PBNode).options(joinedload_all("_lAllChildren"))\
128
       return DBSession.query(pbmd.PBNode).options(joinedload_all("_lAllChildren"))\
136
         .filter(pbmd.PBNode.node_id==liNodeId)\
129
         .filter(pbmd.PBNode.node_id==liNodeId)\
143
         .one()
136
         .one()
144
     return None
137
     return None
145
 
138
 
146
-  def getLastModifiedNodes(self, piMaxNodeNb):
139
+  def getLastModifiedNodes(self, piMaxNodeNb: int):
147
     """
140
     """
148
     Returns a list of nodes order by modification time and limited to piMaxNodeNb nodes
141
     Returns a list of nodes order by modification time and limited to piMaxNodeNb nodes
149
     """
142
     """
151
     return DBSession.query(pbmd.PBNode).options(joinedload_all("_lAllChildren")).filter(pbmd.PBNode.owner_id.in_(liOwnerIdList)).order_by(pbmd.PBNode.updated_at.desc()).limit(piMaxNodeNb).all()
144
     return DBSession.query(pbmd.PBNode).options(joinedload_all("_lAllChildren")).filter(pbmd.PBNode.owner_id.in_(liOwnerIdList)).order_by(pbmd.PBNode.updated_at.desc()).limit(piMaxNodeNb).all()
152
 
145
 
153
 
146
 
154
-  def searchNodesByText(self, plKeywordList, piMaxNodeNb=100):
147
+  def searchNodesByText(self, plKeywordList: [str], piMaxNodeNb=100):
155
     """
148
     """
156
     Returns a list of nodes order by type, nodes which contain at least one of the keywords
149
     Returns a list of nodes order by type, nodes which contain at least one of the keywords
157
     """
150
     """