Browse Source

add some annotations + clean code

Damien Accorsi 10 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,28 +109,21 @@ class PODUserFilteredApiController(object):
109 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 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 125
     lsNodeIdFiltering = lsSqlSelectQuery % (str(self._iCurrentUserId))
133
-    print("filter: ====>>>", lsNodeIdFiltering)
126
+
134 127
     if liNodeId!=0:
135 128
       return DBSession.query(pbmd.PBNode).options(joinedload_all("_lAllChildren"))\
136 129
         .filter(pbmd.PBNode.node_id==liNodeId)\
@@ -143,7 +136,7 @@ WHERE
143 136
         .one()
144 137
     return None
145 138
 
146
-  def getLastModifiedNodes(self, piMaxNodeNb):
139
+  def getLastModifiedNodes(self, piMaxNodeNb: int):
147 140
     """
148 141
     Returns a list of nodes order by modification time and limited to piMaxNodeNb nodes
149 142
     """
@@ -151,7 +144,7 @@ WHERE
151 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 149
     Returns a list of nodes order by type, nodes which contain at least one of the keywords
157 150
     """