annotate ZDBInterfaceFolder.py @ 22:7ee835840724 default tip

fix problem with config page when autocommit is not defined.
author casties
date Wed, 24 Apr 2013 20:49:42 +0200
parents 9fb0d4f24486
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
1 '''
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
2 Created on 14.2.2011
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
3
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
4 @author: casties
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
5 '''
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
6
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
7 from OFS.Folder import Folder
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
8 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
9 from AccessControl import getSecurityManager, Unauthorized
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
10 import logging
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
11 import re
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
12
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
13 from DBInterface import *
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
14
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
15
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
16 class ZDBInterfaceFolder(DBInterface, Folder):
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
17 """Folder for database queries
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
18 """
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
19
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
20 meta_type="ZDBInterfaceFolder"
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
21 manage_options=Folder.manage_options+(
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
22 {'label':'Config','action':'manage_editZDBInterfaceFolderForm'},
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
23 )
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
24
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
25 # management templates
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
26 manage_editZDBInterfaceFolderForm=PageTemplateFile('zpt/editZDBInterfaceFolder',globals())
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
27
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
28
9
87087f4f4059 fixed bug with default sort order.
root@xserve09.mpiwg-berlin.mpg.de
parents: 8
diff changeset
29 def __init__(self, id, title, connection_id=None, autocommit=False, default_search='bw'):
3
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
30 """init"""
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
31 self.id = id
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
32 self.title = title
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
33 # database connection id
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
34 self.connection_id = connection_id
9
87087f4f4059 fixed bug with default sort order.
root@xserve09.mpiwg-berlin.mpg.de
parents: 8
diff changeset
35 # set db connection to autocommit
8
17b19345d011 added autocommit option.
casties
parents: 7
diff changeset
36 self.autocommit = autocommit
9
87087f4f4059 fixed bug with default sort order.
root@xserve09.mpiwg-berlin.mpg.de
parents: 8
diff changeset
37 # default text search mode
87087f4f4059 fixed bug with default sort order.
root@xserve09.mpiwg-berlin.mpg.de
parents: 8
diff changeset
38 self.default_search = default_search
3
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
39
13
cf03ab908a2b add _ignore_empty option (default=true) to ZSQLInlineSearch.
casties
parents: 12
diff changeset
40 def getSQLQuery(self, table, argv, ignore_empty=False):
cf03ab908a2b add _ignore_empty option (default=true) to ZSQLInlineSearch.
casties
parents: 12
diff changeset
41 """returns dict with SQL query string and args.
cf03ab908a2b add _ignore_empty option (default=true) to ZSQLInlineSearch.
casties
parents: 12
diff changeset
42 ignore_empty: remove fields with empty string values from query."""
cf03ab908a2b add _ignore_empty option (default=true) to ZSQLInlineSearch.
casties
parents: 12
diff changeset
43 logging.debug("getSQLquery table=%s argv=%s ignore_empty=%s"%(table,argv,ignore_empty))
4
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
44 args = []
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
45 select = "*"
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
46 order = None
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
47 wheres = []
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
48 whereOp = "AND"
8
17b19345d011 added autocommit option.
casties
parents: 7
diff changeset
49 processed = {}
17b19345d011 added autocommit option.
casties
parents: 7
diff changeset
50 unprocessed = {}
13
cf03ab908a2b add _ignore_empty option (default=true) to ZSQLInlineSearch.
casties
parents: 12
diff changeset
51 ignored = {}
7
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
52 limit = None
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
53 offset = None
5
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
54
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
55 def doOp(op, param, val):
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
56 # handles comparison operations in WHERE clause
7
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
57 logging.debug("doop op=%s param=%s val=%s"%(op,param,val))
13
cf03ab908a2b add _ignore_empty option (default=true) to ZSQLInlineSearch.
casties
parents: 12
diff changeset
58 if ignore_empty and not val:
cf03ab908a2b add _ignore_empty option (default=true) to ZSQLInlineSearch.
casties
parents: 12
diff changeset
59 # ignore parameter
cf03ab908a2b add _ignore_empty option (default=true) to ZSQLInlineSearch.
casties
parents: 12
diff changeset
60 logging.debug(" param=%s ignored"%(param))
cf03ab908a2b add _ignore_empty option (default=true) to ZSQLInlineSearch.
casties
parents: 12
diff changeset
61 return
cf03ab908a2b add _ignore_empty option (default=true) to ZSQLInlineSearch.
casties
parents: 12
diff changeset
62
5
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
63 if isinstance(val, list):
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
64 # join multiple parameters with spaces (makes sense with checkbox and -op=all)
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
65 val = " ".join(val)
7
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
66
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
67 # string comparisons are case-insensitive
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
68 if isinstance(val, basestring):
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
69 param = "LOWER(%s)"%param
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
70 val = val.lower()
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
71
5
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
72 if op == "eq":
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
73 wheres.append(param + " = %s")
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
74 args.append(val)
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
75 elif op == "lt":
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
76 wheres.append(param + " < %s")
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
77 args.append(val)
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
78 elif op == "gt":
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
79 wheres.append(param + " > %s")
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
80 args.append(val)
9
87087f4f4059 fixed bug with default sort order.
root@xserve09.mpiwg-berlin.mpg.de
parents: 8
diff changeset
81 elif op == "ew":
7
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
82 wheres.append(param + " ILIKE %s")
5
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
83 args.append("%" + val)
9
87087f4f4059 fixed bug with default sort order.
root@xserve09.mpiwg-berlin.mpg.de
parents: 8
diff changeset
84 elif op == "bw":
7
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
85 wheres.append(param + " ILIKE %s")
5
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
86 args.append(val + "%")
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
87 elif op == "ct":
7
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
88 wheres.append(param + " ILIKE %s")
5
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
89 args.append("%" + val + "%")
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
90 elif op == "all":
15
9fb0d4f24486 comments with a bit of documentation
casties
parents: 14
diff changeset
91 # p="a b c" -> WHERE (p ILIKE '%a%' AND p ILIKE '%b%' AND p ILIKE '%c%')
5
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
92 words = []
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
93 for word in val.split(" "):
7
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
94 words.append(param + " ILIKE %s")
5
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
95 args.append("%" + word + "%")
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
96 wheres.append("(" + " AND ".join(words) + ")")
7
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
97 elif op == "one":
15
9fb0d4f24486 comments with a bit of documentation
casties
parents: 14
diff changeset
98 # p="a b c" -> WHERE (p ILIKE '%a%' OR p ILIKE '%b%' OR p ILIKE '%c%')
7
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
99 words = []
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
100 for word in val.split(" "):
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
101 words.append(param + " ILIKE %s")
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
102 args.append("%" + word + "%")
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
103 wheres.append("(" + " OR ".join(words) + ")")
14
9cea47dc6926 added _op_XXX=in operation
casties
parents: 13
diff changeset
104 elif op == "in":
15
9fb0d4f24486 comments with a bit of documentation
casties
parents: 14
diff changeset
105 # p="a b c" -> WHERE p IN ('a', 'b', 'c')
14
9cea47dc6926 added _op_XXX=in operation
casties
parents: 13
diff changeset
106 words = []
9cea47dc6926 added _op_XXX=in operation
casties
parents: 13
diff changeset
107 for word in val.split(" "):
9cea47dc6926 added _op_XXX=in operation
casties
parents: 13
diff changeset
108 words.append("%s")
9cea47dc6926 added _op_XXX=in operation
casties
parents: 13
diff changeset
109 args.append(word)
15
9fb0d4f24486 comments with a bit of documentation
casties
parents: 14
diff changeset
110 wheres.append(param + " IN (" + ", ".join(words) + ")")
5
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
111 else:
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
112 logging.error("getSQLquery: unknown op=%s!"%op)
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
113
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
114 return
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
115
4
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
116 # evaluate argv
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
117 for (key, val) in argv.items():
9
87087f4f4059 fixed bug with default sort order.
root@xserve09.mpiwg-berlin.mpg.de
parents: 8
diff changeset
118 logging.debug("process key=%s val=%s"%(key,val))
8
17b19345d011 added autocommit option.
casties
parents: 7
diff changeset
119 if key in processed:
4
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
120 # parameter has been processed
9
87087f4f4059 fixed bug with default sort order.
root@xserve09.mpiwg-berlin.mpg.de
parents: 8
diff changeset
121 logging.debug(" key=%s processed"%(key))
4
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
122 continue
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
123
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
124 # beginning of a command should always be "_"
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
125 if key[0] == "-":
5
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
126 key = "_" + key[1:]
4
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
127
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
128 if key == "_select":
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
129 # SELECT expression
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
130 select = sqlName(val, more="*,")
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
131 elif key == "_sort":
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
132 # sort i.e. ORDER BY expression
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
133 order = sqlName(val, more=",")
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
134 elif key == "_lop":
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
135 # logical operation joining WHERE clauses
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
136 whereOp = sqlName(val)
12
09882d5a3989 fix bug with _max and _skip. add _size and _start as alias.
casties
parents: 10
diff changeset
137 elif key == "_max" or key == "_size":
7
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
138 # number of results
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
139 limit = sqlName(val)
12
09882d5a3989 fix bug with _max and _skip. add _size and _start as alias.
casties
parents: 10
diff changeset
140 elif key == "_skip" or key == "_start":
7
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
141 # start at result number
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
142 offset = sqlName(val)
4
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
143 elif key[:3] == "_op":
10
283c01ebe96e cleaned comments
casties
parents: 9
diff changeset
144 # operation parameters _op_param=val
4
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
145 param = sqlName(key[4:])
5
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
146 logging.debug("param=%s key=%s val=%s"%(param,key,val))
4
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
147 if param in argv:
5
ca30cf0e810d fix bugs in ZDBInlineSearch.
root@xserve09.mpiwg-berlin.mpg.de
parents: 4
diff changeset
148 doOp(val, param, argv[param])
8
17b19345d011 added autocommit option.
casties
parents: 7
diff changeset
149 processed[param] = True
4
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
150 else:
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
151 # no corresponding parameter
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
152 logging.error("getSQLquery: param=%s for op not found!"%param)
8
17b19345d011 added autocommit option.
casties
parents: 7
diff changeset
153 else:
17b19345d011 added autocommit option.
casties
parents: 7
diff changeset
154 # parameter=value pair
17b19345d011 added autocommit option.
casties
parents: 7
diff changeset
155 unprocessed[key] = val
4
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
156
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
157 # process remaining parameters (without _op)
8
17b19345d011 added autocommit option.
casties
parents: 7
diff changeset
158 for (key, val) in unprocessed.items():
9
87087f4f4059 fixed bug with default sort order.
root@xserve09.mpiwg-berlin.mpg.de
parents: 8
diff changeset
159 if key not in processed:
87087f4f4059 fixed bug with default sort order.
root@xserve09.mpiwg-berlin.mpg.de
parents: 8
diff changeset
160 param = sqlName(key)
87087f4f4059 fixed bug with default sort order.
root@xserve09.mpiwg-berlin.mpg.de
parents: 8
diff changeset
161 # default operation
87087f4f4059 fixed bug with default sort order.
root@xserve09.mpiwg-berlin.mpg.de
parents: 8
diff changeset
162 doOp(self.default_search, param, val)
4
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
163
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
164 # join it all
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
165 query = "SELECT %s FROM %s"%(select, table)
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
166 if wheres:
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
167 query += " WHERE " + (" " + whereOp + " ").join(wheres)
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
168
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
169 if order:
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
170 query += " ORDER BY " + order
7
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
171
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
172 if limit:
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
173 query += " LIMIT " + limit
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
174
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
175 if offset:
917e28a08c58 search case insensitive. max and skip options.
casties
parents: 5
diff changeset
176 query += " OFFSET " + offset
4
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
177
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
178 return {'query' : query, 'args' : args}
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
179
13
cf03ab908a2b add _ignore_empty option (default=true) to ZSQLInlineSearch.
casties
parents: 12
diff changeset
180 def ZDBInlineSearch(self, _table=None, _ignore_empty=True, **argv):
10
283c01ebe96e cleaned comments
casties
parents: 9
diff changeset
181 """returns result set from search with given parameters"""
13
cf03ab908a2b add _ignore_empty option (default=true) to ZSQLInlineSearch.
casties
parents: 12
diff changeset
182 query = self.getSQLQuery(_table, argv, ignore_empty= _ignore_empty)
4
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
183 result = self.executeZSQL(query['query'], query['args'])
0ade331198de first version of ZDBInlineSearch
casties
parents: 3
diff changeset
184 return result
3
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
185
9
87087f4f4059 fixed bug with default sort order.
root@xserve09.mpiwg-berlin.mpg.de
parents: 8
diff changeset
186 def manage_editZDBInterfaceFolder(self, title=None, connection_id=None, autocommit=None, default_search=None,
3
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
187 REQUEST=None):
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
188 """Change the object"""
9
87087f4f4059 fixed bug with default sort order.
root@xserve09.mpiwg-berlin.mpg.de
parents: 8
diff changeset
189 logging.debug("editZDBInterfaceFolder title=%s, connection_id=%s, autocommit=%s default_search=%s"%(title,connection_id,autocommit,default_search))
3
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
190 if title is not None:
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
191 self.title = title
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
192
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
193 if connection_id is not None:
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
194 self.connection_id = connection_id
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
195
9
87087f4f4059 fixed bug with default sort order.
root@xserve09.mpiwg-berlin.mpg.de
parents: 8
diff changeset
196 if default_search is not None:
87087f4f4059 fixed bug with default sort order.
root@xserve09.mpiwg-berlin.mpg.de
parents: 8
diff changeset
197 self.default_search = default_search
87087f4f4059 fixed bug with default sort order.
root@xserve09.mpiwg-berlin.mpg.de
parents: 8
diff changeset
198
8
17b19345d011 added autocommit option.
casties
parents: 7
diff changeset
199 self.autocommit = (autocommit == "on")
17b19345d011 added autocommit option.
casties
parents: 7
diff changeset
200
3
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
201 #checkPermission=getSecurityManager().checkPermission
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
202 REQUEST.RESPONSE.redirect('manage_main')
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
203
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
204
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
205 manage_addZDBInterfaceFolderForm=PageTemplateFile('zpt/addZDBInterfaceFolder',globals())
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
206
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
207 def manage_addZDBInterfaceFolder(self, id, title='', label='', description='',
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
208 createPublic=0,
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
209 createUserF=0,
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
210 REQUEST=None):
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
211 """Add a new object with id *id*."""
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
212
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
213 ob=ZDBInterfaceFolder(str(id),title)
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
214 self._setObject(id, ob)
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
215
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
216 #checkPermission=getSecurityManager().checkPermission
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
217 REQUEST.RESPONSE.redirect('manage_main')
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
218
d70e57193731 new executeZSQL method that returns Zope Results.
casties
parents:
diff changeset
219