annotate MPIWGFMItem.py @ 0:957bcf42f206

initial
author dwinter
date Thu, 02 May 2013 08:33:53 +0200
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
957bcf42f206 initial
dwinter
parents:
diff changeset
1 from AccessControl import ClassSecurityInfo
957bcf42f206 initial
dwinter
parents:
diff changeset
2 from OFS.Folder import Folder
957bcf42f206 initial
dwinter
parents:
diff changeset
3 from OFS.PropertyManager import PropertyManager
957bcf42f206 initial
dwinter
parents:
diff changeset
4 import OFS.Image
957bcf42f206 initial
dwinter
parents:
diff changeset
5 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
957bcf42f206 initial
dwinter
parents:
diff changeset
6 from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
957bcf42f206 initial
dwinter
parents:
diff changeset
7 from ZPublisher.Converters import type_converters
957bcf42f206 initial
dwinter
parents:
diff changeset
8
957bcf42f206 initial
dwinter
parents:
diff changeset
9 import Acquisition
957bcf42f206 initial
dwinter
parents:
diff changeset
10
957bcf42f206 initial
dwinter
parents:
diff changeset
11 import datetime
957bcf42f206 initial
dwinter
parents:
diff changeset
12 import random
957bcf42f206 initial
dwinter
parents:
diff changeset
13 import logging
957bcf42f206 initial
dwinter
parents:
diff changeset
14
957bcf42f206 initial
dwinter
parents:
diff changeset
15 from OFS.Cache import Cacheable
957bcf42f206 initial
dwinter
parents:
diff changeset
16
957bcf42f206 initial
dwinter
parents:
diff changeset
17 NS ="{http://www.filemaker.com/xml/fmresultset}"
957bcf42f206 initial
dwinter
parents:
diff changeset
18
957bcf42f206 initial
dwinter
parents:
diff changeset
19 class MPIWGFMItem(Folder, PropertyManager, Cacheable):
957bcf42f206 initial
dwinter
parents:
diff changeset
20 """
957bcf42f206 initial
dwinter
parents:
diff changeset
21
957bcf42f206 initial
dwinter
parents:
diff changeset
22 """
957bcf42f206 initial
dwinter
parents:
diff changeset
23
957bcf42f206 initial
dwinter
parents:
diff changeset
24 meta_type = 'MPIWGItem'
957bcf42f206 initial
dwinter
parents:
diff changeset
25 title = ""
957bcf42f206 initial
dwinter
parents:
diff changeset
26
957bcf42f206 initial
dwinter
parents:
diff changeset
27 _properties = ({'id':'title', 'type':'string'},)
957bcf42f206 initial
dwinter
parents:
diff changeset
28
957bcf42f206 initial
dwinter
parents:
diff changeset
29 manage_options = (
957bcf42f206 initial
dwinter
parents:
diff changeset
30 {'label':'Edit', 'action':'manage_editItemForm'},
957bcf42f206 initial
dwinter
parents:
diff changeset
31 ) + Folder.manage_options + (
957bcf42f206 initial
dwinter
parents:
diff changeset
32 {'label':'Edit Item', 'action':'manage_editMPIWGItemForm'},
957bcf42f206 initial
dwinter
parents:
diff changeset
33 )
957bcf42f206 initial
dwinter
parents:
diff changeset
34
957bcf42f206 initial
dwinter
parents:
diff changeset
35 #def __init__(self,id, date=None, cat_en="", cat_de="", title_en="", title_de=""):
957bcf42f206 initial
dwinter
parents:
diff changeset
36
957bcf42f206 initial
dwinter
parents:
diff changeset
37 def findText(self,record,xpath):
957bcf42f206 initial
dwinter
parents:
diff changeset
38
957bcf42f206 initial
dwinter
parents:
diff changeset
39 tmp = record.find(xpath)
957bcf42f206 initial
dwinter
parents:
diff changeset
40
957bcf42f206 initial
dwinter
parents:
diff changeset
41 if tmp is not None:
957bcf42f206 initial
dwinter
parents:
diff changeset
42 return unicode(tmp[0].text)
957bcf42f206 initial
dwinter
parents:
diff changeset
43 else:
957bcf42f206 initial
dwinter
parents:
diff changeset
44 return ""
957bcf42f206 initial
dwinter
parents:
diff changeset
45
957bcf42f206 initial
dwinter
parents:
diff changeset
46 def __init__(self,record,folder):
957bcf42f206 initial
dwinter
parents:
diff changeset
47 self.id = id
957bcf42f206 initial
dwinter
parents:
diff changeset
48 #self.Category = (cat_en,cat_de)
957bcf42f206 initial
dwinter
parents:
diff changeset
49
957bcf42f206 initial
dwinter
parents:
diff changeset
50 xpathstr = ".//"+NS+"field[@name='%s']"
957bcf42f206 initial
dwinter
parents:
diff changeset
51
957bcf42f206 initial
dwinter
parents:
diff changeset
52
957bcf42f206 initial
dwinter
parents:
diff changeset
53 title_de = self.findText(record,xpathstr%"Titel")
957bcf42f206 initial
dwinter
parents:
diff changeset
54
957bcf42f206 initial
dwinter
parents:
diff changeset
55 title_en = self.findText(record,xpathstr%"EN_Titel")
957bcf42f206 initial
dwinter
parents:
diff changeset
56
957bcf42f206 initial
dwinter
parents:
diff changeset
57
957bcf42f206 initial
dwinter
parents:
diff changeset
58 self.Title = (title_en,title_de)
957bcf42f206 initial
dwinter
parents:
diff changeset
59
957bcf42f206 initial
dwinter
parents:
diff changeset
60
957bcf42f206 initial
dwinter
parents:
diff changeset
61 date = self.findText(record,xpathstr%"TagderVeranstaltung")
957bcf42f206 initial
dwinter
parents:
diff changeset
62
957bcf42f206 initial
dwinter
parents:
diff changeset
63
957bcf42f206 initial
dwinter
parents:
diff changeset
64 if date == "" or date is None:
957bcf42f206 initial
dwinter
parents:
diff changeset
65 date = datetime.date.today().strftime("%d.%m.%Y")
957bcf42f206 initial
dwinter
parents:
diff changeset
66
957bcf42f206 initial
dwinter
parents:
diff changeset
67
957bcf42f206 initial
dwinter
parents:
diff changeset
68
957bcf42f206 initial
dwinter
parents:
diff changeset
69 self.Date = self.parseDate(date) # sorting date
957bcf42f206 initial
dwinter
parents:
diff changeset
70
957bcf42f206 initial
dwinter
parents:
diff changeset
71 self.Properties = [] # List of 6 Tuples (ID_EN,ID_DE,VALUE_EN,VALUE_DE, WEIGHT,ID)
957bcf42f206 initial
dwinter
parents:
diff changeset
72 # Note: ID_EN is the identifier for the getter-methods
957bcf42f206 initial
dwinter
parents:
diff changeset
73
957bcf42f206 initial
dwinter
parents:
diff changeset
74 self.title = title_en
957bcf42f206 initial
dwinter
parents:
diff changeset
75
957bcf42f206 initial
dwinter
parents:
diff changeset
76 self.getDataFromRecord(record, folder)
957bcf42f206 initial
dwinter
parents:
diff changeset
77
957bcf42f206 initial
dwinter
parents:
diff changeset
78 def index_html(self):
957bcf42f206 initial
dwinter
parents:
diff changeset
79 """index method"""
957bcf42f206 initial
dwinter
parents:
diff changeset
80 # default template is called item_main
957bcf42f206 initial
dwinter
parents:
diff changeset
81 pt = getattr(self, 'item_main', None)
957bcf42f206 initial
dwinter
parents:
diff changeset
82 if pt is not None:
957bcf42f206 initial
dwinter
parents:
diff changeset
83 return pt()
957bcf42f206 initial
dwinter
parents:
diff changeset
84
957bcf42f206 initial
dwinter
parents:
diff changeset
85 # else try parent
957bcf42f206 initial
dwinter
parents:
diff changeset
86 if hasattr(self.aq_parent, 'index_html'):
957bcf42f206 initial
dwinter
parents:
diff changeset
87 return self.aq_parent.index_html()
957bcf42f206 initial
dwinter
parents:
diff changeset
88
957bcf42f206 initial
dwinter
parents:
diff changeset
89
957bcf42f206 initial
dwinter
parents:
diff changeset
90 def parseDate(self, date):
957bcf42f206 initial
dwinter
parents:
diff changeset
91 # parse the date from a DD.MM.YYYY string
957bcf42f206 initial
dwinter
parents:
diff changeset
92
957bcf42f206 initial
dwinter
parents:
diff changeset
93 try:
957bcf42f206 initial
dwinter
parents:
diff changeset
94 digits = [int(x) for x in date.split(".")]
957bcf42f206 initial
dwinter
parents:
diff changeset
95 return datetime.date(digits[2],digits[1],digits[0])
957bcf42f206 initial
dwinter
parents:
diff changeset
96 except: #try MM/TT/YYYY
957bcf42f206 initial
dwinter
parents:
diff changeset
97 digits = [int(x) for x in date.split("/")]
957bcf42f206 initial
dwinter
parents:
diff changeset
98 return datetime.date(digits[2],digits[0],digits[1])
957bcf42f206 initial
dwinter
parents:
diff changeset
99
957bcf42f206 initial
dwinter
parents:
diff changeset
100 def getDate(self):
957bcf42f206 initial
dwinter
parents:
diff changeset
101 """ return the date """
957bcf42f206 initial
dwinter
parents:
diff changeset
102 return self.Date.strftime("%d.%m.%Y")
957bcf42f206 initial
dwinter
parents:
diff changeset
103
957bcf42f206 initial
dwinter
parents:
diff changeset
104 def getProperty(self, id):
957bcf42f206 initial
dwinter
parents:
diff changeset
105 for prop in self.Properties:
957bcf42f206 initial
dwinter
parents:
diff changeset
106 if len(prop)==5: # add ID to the old format
957bcf42f206 initial
dwinter
parents:
diff changeset
107 prop = (prop[0],prop[1],prop[2],prop[3],prop[4],prop[0])
957bcf42f206 initial
dwinter
parents:
diff changeset
108 if prop[5].lower() == id.lower():
957bcf42f206 initial
dwinter
parents:
diff changeset
109 return prop
957bcf42f206 initial
dwinter
parents:
diff changeset
110 #if id_en == "category":
957bcf42f206 initial
dwinter
parents:
diff changeset
111 # return ("Category","Kategorie",self.Category[0],self.Category[1],0)
957bcf42f206 initial
dwinter
parents:
diff changeset
112 if id == "title":
957bcf42f206 initial
dwinter
parents:
diff changeset
113 return ("Title", "Titel", self.Title[0], self.Title[1],0,"title")
957bcf42f206 initial
dwinter
parents:
diff changeset
114 if id == "date":
957bcf42f206 initial
dwinter
parents:
diff changeset
115 return ("Date", "Datum", self.Date.strftime("%d.%m.%Y"), self.Date.strftime("%d.%m.%Y"),0,"date")
957bcf42f206 initial
dwinter
parents:
diff changeset
116 return None
957bcf42f206 initial
dwinter
parents:
diff changeset
117
957bcf42f206 initial
dwinter
parents:
diff changeset
118
957bcf42f206 initial
dwinter
parents:
diff changeset
119 #def getUrl(self, baseUrl=None):
957bcf42f206 initial
dwinter
parents:
diff changeset
120 # """returns URL to this Department"""
957bcf42f206 initial
dwinter
parents:
diff changeset
121 # if baseUrl is None:
957bcf42f206 initial
dwinter
parents:
diff changeset
122 # return self.absolute_url()
957bcf42f206 initial
dwinter
parents:
diff changeset
123 #
957bcf42f206 initial
dwinter
parents:
diff changeset
124 # return '%s/%s'%(baseUrl, self.getId())
957bcf42f206 initial
dwinter
parents:
diff changeset
125
957bcf42f206 initial
dwinter
parents:
diff changeset
126 def getImageIds(self, count=0):
957bcf42f206 initial
dwinter
parents:
diff changeset
127 """ return the ids of images inside this MPIWGItem-object
957bcf42f206 initial
dwinter
parents:
diff changeset
128 not implemented for DB"""
957bcf42f206 initial
dwinter
parents:
diff changeset
129 #ids = self.objectIds(spec="Image")
957bcf42f206 initial
dwinter
parents:
diff changeset
130 #if len(ids) > 1:
957bcf42f206 initial
dwinter
parents:
diff changeset
131 # if count > 0:
957bcf42f206 initial
dwinter
parents:
diff changeset
132 # ids = ids[:count]
957bcf42f206 initial
dwinter
parents:
diff changeset
133 # else:
957bcf42f206 initial
dwinter
parents:
diff changeset
134 # ids = ids[:]
957bcf42f206 initial
dwinter
parents:
diff changeset
135 # ids.sort()
957bcf42f206 initial
dwinter
parents:
diff changeset
136
957bcf42f206 initial
dwinter
parents:
diff changeset
137 return []
957bcf42f206 initial
dwinter
parents:
diff changeset
138
957bcf42f206 initial
dwinter
parents:
diff changeset
139 def getImageUrls(self, count=0, baseUrl=None):
957bcf42f206 initial
dwinter
parents:
diff changeset
140 """ return the urls of images inside this MPIWGItem-object - not implemented for DB"""
957bcf42f206 initial
dwinter
parents:
diff changeset
141 #ids = self.getImageIds(count=count)
957bcf42f206 initial
dwinter
parents:
diff changeset
142 #if baseUrl is None:
957bcf42f206 initial
dwinter
parents:
diff changeset
143 # baseUrl = self.absolute_url()
957bcf42f206 initial
dwinter
parents:
diff changeset
144
957bcf42f206 initial
dwinter
parents:
diff changeset
145 #return ['%s/%s'%(baseUrl,id) for id in ids]
957bcf42f206 initial
dwinter
parents:
diff changeset
146 return []
957bcf42f206 initial
dwinter
parents:
diff changeset
147 def getImageUrl(self, idx=0, baseUrl=None):
957bcf42f206 initial
dwinter
parents:
diff changeset
148 """ return the url of an image inside this MPIWGItem-object -not impelemted for DB"""
957bcf42f206 initial
dwinter
parents:
diff changeset
149 #ids = self.getImageIds(count=idx+1)
957bcf42f206 initial
dwinter
parents:
diff changeset
150 #if len(ids) < idx+1:
957bcf42f206 initial
dwinter
parents:
diff changeset
151 # return None
957bcf42f206 initial
dwinter
parents:
diff changeset
152 #
957bcf42f206 initial
dwinter
parents:
diff changeset
153 #if baseUrl is None:
957bcf42f206 initial
dwinter
parents:
diff changeset
154 # baseUrl = self.absolute_url()
957bcf42f206 initial
dwinter
parents:
diff changeset
155 #
957bcf42f206 initial
dwinter
parents:
diff changeset
156 #return '%s/%s'%(baseUrl,ids[idx])
957bcf42f206 initial
dwinter
parents:
diff changeset
157 return ""
957bcf42f206 initial
dwinter
parents:
diff changeset
158
957bcf42f206 initial
dwinter
parents:
diff changeset
159 def getFileIds(self, count=0):
957bcf42f206 initial
dwinter
parents:
diff changeset
160 """ return the ids of files inside this MPIWGItem-object --not impelemted for DB"""
957bcf42f206 initial
dwinter
parents:
diff changeset
161 #ids = self.objectIds(spec="File")
957bcf42f206 initial
dwinter
parents:
diff changeset
162 #if len(ids) > 1:
957bcf42f206 initial
dwinter
parents:
diff changeset
163 # if count > 0:
957bcf42f206 initial
dwinter
parents:
diff changeset
164 # ids = ids[:count]
957bcf42f206 initial
dwinter
parents:
diff changeset
165
957bcf42f206 initial
dwinter
parents:
diff changeset
166 #else:
957bcf42f206 initial
dwinter
parents:
diff changeset
167 # ids = ids[:]
957bcf42f206 initial
dwinter
parents:
diff changeset
168 #ids.sort()
957bcf42f206 initial
dwinter
parents:
diff changeset
169
957bcf42f206 initial
dwinter
parents:
diff changeset
170 #return ids
957bcf42f206 initial
dwinter
parents:
diff changeset
171 return[]
957bcf42f206 initial
dwinter
parents:
diff changeset
172
957bcf42f206 initial
dwinter
parents:
diff changeset
173 def getFileUrls(self, baseUrl=None, count=0):
957bcf42f206 initial
dwinter
parents:
diff changeset
174 """ return the urls of files inside this MPIWGItem-object -not impelemted for DB"""
957bcf42f206 initial
dwinter
parents:
diff changeset
175 # ids = self.getFileIds(count=count)
957bcf42f206 initial
dwinter
parents:
diff changeset
176 # if baseUrl is None:
957bcf42f206 initial
dwinter
parents:
diff changeset
177 # baseUrl = self.absolute_url()
957bcf42f206 initial
dwinter
parents:
diff changeset
178 #
957bcf42f206 initial
dwinter
parents:
diff changeset
179 # return ['%s/%s'%(baseUrl,id) for id in ids]
957bcf42f206 initial
dwinter
parents:
diff changeset
180 return []
957bcf42f206 initial
dwinter
parents:
diff changeset
181
957bcf42f206 initial
dwinter
parents:
diff changeset
182 def getPropertyKeys(self):
957bcf42f206 initial
dwinter
parents:
diff changeset
183 """ """
957bcf42f206 initial
dwinter
parents:
diff changeset
184 return [x[5] for x in self.Properties if len(x)==6]+[x[0] for x in self.Properties if len(x)==5]
957bcf42f206 initial
dwinter
parents:
diff changeset
185
957bcf42f206 initial
dwinter
parents:
diff changeset
186 def getWeight(self, index):
957bcf42f206 initial
dwinter
parents:
diff changeset
187 """ """
957bcf42f206 initial
dwinter
parents:
diff changeset
188 return self.Properties[index][4]
957bcf42f206 initial
dwinter
parents:
diff changeset
189
957bcf42f206 initial
dwinter
parents:
diff changeset
190
957bcf42f206 initial
dwinter
parents:
diff changeset
191 def getByPrefix(self, prefix):
957bcf42f206 initial
dwinter
parents:
diff changeset
192 """ returns all items with the same prefix in the ID """
957bcf42f206 initial
dwinter
parents:
diff changeset
193 return [ prop for prop in self.Properties if prop[5].find(prefix)==0 ]
957bcf42f206 initial
dwinter
parents:
diff changeset
194
957bcf42f206 initial
dwinter
parents:
diff changeset
195
957bcf42f206 initial
dwinter
parents:
diff changeset
196 def getValue(self, id, lang="EN"):
957bcf42f206 initial
dwinter
parents:
diff changeset
197 """ """
957bcf42f206 initial
dwinter
parents:
diff changeset
198 prop = self.getProperty(id)
957bcf42f206 initial
dwinter
parents:
diff changeset
199 if prop==None:
957bcf42f206 initial
dwinter
parents:
diff changeset
200 return None
957bcf42f206 initial
dwinter
parents:
diff changeset
201 if lang=="DE":
957bcf42f206 initial
dwinter
parents:
diff changeset
202 return prop[3]
957bcf42f206 initial
dwinter
parents:
diff changeset
203 else:
957bcf42f206 initial
dwinter
parents:
diff changeset
204 return prop[2]
957bcf42f206 initial
dwinter
parents:
diff changeset
205
957bcf42f206 initial
dwinter
parents:
diff changeset
206 getInfo = getValue # compatibility
957bcf42f206 initial
dwinter
parents:
diff changeset
207
957bcf42f206 initial
dwinter
parents:
diff changeset
208 def getCaption(self, id, lang="EN"):
957bcf42f206 initial
dwinter
parents:
diff changeset
209 """ """
957bcf42f206 initial
dwinter
parents:
diff changeset
210 prop = self.getProperty(id)
957bcf42f206 initial
dwinter
parents:
diff changeset
211 if prop==None:
957bcf42f206 initial
dwinter
parents:
diff changeset
212 return None
957bcf42f206 initial
dwinter
parents:
diff changeset
213 if lang=="DE":
957bcf42f206 initial
dwinter
parents:
diff changeset
214 return prop[1]
957bcf42f206 initial
dwinter
parents:
diff changeset
215 else:
957bcf42f206 initial
dwinter
parents:
diff changeset
216 return prop[0]
957bcf42f206 initial
dwinter
parents:
diff changeset
217
957bcf42f206 initial
dwinter
parents:
diff changeset
218
957bcf42f206 initial
dwinter
parents:
diff changeset
219 def getItems(self, lang="EN", excepts=[]):
957bcf42f206 initial
dwinter
parents:
diff changeset
220 """ returns all the key/value pairs """
957bcf42f206 initial
dwinter
parents:
diff changeset
221
957bcf42f206 initial
dwinter
parents:
diff changeset
222 if lang=="DE":
957bcf42f206 initial
dwinter
parents:
diff changeset
223 return [(prop[1],prop[3]) for prop in self.Properties if not prop[0].lower() in excepts]
957bcf42f206 initial
dwinter
parents:
diff changeset
224 else:
957bcf42f206 initial
dwinter
parents:
diff changeset
225 return [(prop[0],prop[2]) for prop in self.Properties if not prop[0].lower() in excepts]
957bcf42f206 initial
dwinter
parents:
diff changeset
226
957bcf42f206 initial
dwinter
parents:
diff changeset
227 getAllInfo = getItems # compatibility
957bcf42f206 initial
dwinter
parents:
diff changeset
228
957bcf42f206 initial
dwinter
parents:
diff changeset
229 def addProperty(self, tup=("","","","",0,"")):
957bcf42f206 initial
dwinter
parents:
diff changeset
230 """ """
957bcf42f206 initial
dwinter
parents:
diff changeset
231 self.Properties.append(tup)
957bcf42f206 initial
dwinter
parents:
diff changeset
232 # force update of the Properties list in the ZopeDB
957bcf42f206 initial
dwinter
parents:
diff changeset
233 self._p_changed = 1
957bcf42f206 initial
dwinter
parents:
diff changeset
234
957bcf42f206 initial
dwinter
parents:
diff changeset
235
957bcf42f206 initial
dwinter
parents:
diff changeset
236
957bcf42f206 initial
dwinter
parents:
diff changeset
237 def setProperty(self, tup):
957bcf42f206 initial
dwinter
parents:
diff changeset
238 """ set the data of a property; tup is a tuple, structured like the properties """
957bcf42f206 initial
dwinter
parents:
diff changeset
239 # find the property
957bcf42f206 initial
dwinter
parents:
diff changeset
240 num = -1
957bcf42f206 initial
dwinter
parents:
diff changeset
241 for i in range(len(self.Properties)):
957bcf42f206 initial
dwinter
parents:
diff changeset
242 if self.Properties[i][5] == tup[5]:
957bcf42f206 initial
dwinter
parents:
diff changeset
243 num = i
957bcf42f206 initial
dwinter
parents:
diff changeset
244
957bcf42f206 initial
dwinter
parents:
diff changeset
245 # List of 6 Tuples (ID_EN,ID_DE,VALUE_EN,VALUE_DE, WEIGHT,ID)
957bcf42f206 initial
dwinter
parents:
diff changeset
246 # update it
957bcf42f206 initial
dwinter
parents:
diff changeset
247 if num != -1:
957bcf42f206 initial
dwinter
parents:
diff changeset
248 self.Properties[num] = tup
957bcf42f206 initial
dwinter
parents:
diff changeset
249 # force update of the Properties list in the ZopeDB
957bcf42f206 initial
dwinter
parents:
diff changeset
250 self._p_changed = 1
957bcf42f206 initial
dwinter
parents:
diff changeset
251
957bcf42f206 initial
dwinter
parents:
diff changeset
252
957bcf42f206 initial
dwinter
parents:
diff changeset
253 def delProperty(self, id):
957bcf42f206 initial
dwinter
parents:
diff changeset
254 """ remove a property """
957bcf42f206 initial
dwinter
parents:
diff changeset
255 num = -1
957bcf42f206 initial
dwinter
parents:
diff changeset
256 for i in range(len(self.Properties)):
957bcf42f206 initial
dwinter
parents:
diff changeset
257 if self.Properties[i][5] == id:
957bcf42f206 initial
dwinter
parents:
diff changeset
258 del self.Properties[i]
957bcf42f206 initial
dwinter
parents:
diff changeset
259 # force update of the Properties list in the ZopeDB
957bcf42f206 initial
dwinter
parents:
diff changeset
260 self._p_changed = 1
957bcf42f206 initial
dwinter
parents:
diff changeset
261
957bcf42f206 initial
dwinter
parents:
diff changeset
262 return
957bcf42f206 initial
dwinter
parents:
diff changeset
263
957bcf42f206 initial
dwinter
parents:
diff changeset
264 def getNextGroupPropertyIndex(self, prefix):
957bcf42f206 initial
dwinter
parents:
diff changeset
265 """ returns the logical next id for a property with a certain 'prefix'
957bcf42f206 initial
dwinter
parents:
diff changeset
266 e.g. if there are properties 'dl_1' and 'dl_2' and the prefix is 'dl_', then the method will yield 'dl_3'.
957bcf42f206 initial
dwinter
parents:
diff changeset
267 """
957bcf42f206 initial
dwinter
parents:
diff changeset
268 oldproperties = [x[5] for x in self.Properties if x[5].find(prefix)==0 and x[5].split(prefix)[1].isdigit()]
957bcf42f206 initial
dwinter
parents:
diff changeset
269 oldproperties.sort()
957bcf42f206 initial
dwinter
parents:
diff changeset
270 if len(oldproperties)>0:
957bcf42f206 initial
dwinter
parents:
diff changeset
271 lastparam = int(oldproperties[-1].split(prefix)[1])
957bcf42f206 initial
dwinter
parents:
diff changeset
272 return prefix+str(lastparam+1)
957bcf42f206 initial
dwinter
parents:
diff changeset
273 else:
957bcf42f206 initial
dwinter
parents:
diff changeset
274 return prefix+"1"
957bcf42f206 initial
dwinter
parents:
diff changeset
275
957bcf42f206 initial
dwinter
parents:
diff changeset
276 def getHighestGroupPropertyWeight(self, prefix):
957bcf42f206 initial
dwinter
parents:
diff changeset
277 """ """
957bcf42f206 initial
dwinter
parents:
diff changeset
278 propWeights = [x[4] for x in self.Properties if x[5].find(prefix)==0]
957bcf42f206 initial
dwinter
parents:
diff changeset
279 if len(propWeights)>0:
957bcf42f206 initial
dwinter
parents:
diff changeset
280 return max(propWeights)
957bcf42f206 initial
dwinter
parents:
diff changeset
281 else:
957bcf42f206 initial
dwinter
parents:
diff changeset
282 return 0
957bcf42f206 initial
dwinter
parents:
diff changeset
283
957bcf42f206 initial
dwinter
parents:
diff changeset
284 def switchPropertyWeights(self, prop1, prop2):
957bcf42f206 initial
dwinter
parents:
diff changeset
285 """ """
957bcf42f206 initial
dwinter
parents:
diff changeset
286 p1 = list(self.getProperty(prop1))
957bcf42f206 initial
dwinter
parents:
diff changeset
287 p2 = list(self.getProperty(prop2))
957bcf42f206 initial
dwinter
parents:
diff changeset
288
957bcf42f206 initial
dwinter
parents:
diff changeset
289 w1 = p1[4]
957bcf42f206 initial
dwinter
parents:
diff changeset
290 w2 = p2[4]
957bcf42f206 initial
dwinter
parents:
diff changeset
291
957bcf42f206 initial
dwinter
parents:
diff changeset
292 p1[4] = w2
957bcf42f206 initial
dwinter
parents:
diff changeset
293 p2[4] = w1
957bcf42f206 initial
dwinter
parents:
diff changeset
294
957bcf42f206 initial
dwinter
parents:
diff changeset
295 self.setProperty(tuple(p1))
957bcf42f206 initial
dwinter
parents:
diff changeset
296 self.setProperty(tuple(p2))
957bcf42f206 initial
dwinter
parents:
diff changeset
297
957bcf42f206 initial
dwinter
parents:
diff changeset
298 self._p_changed = 1
957bcf42f206 initial
dwinter
parents:
diff changeset
299
957bcf42f206 initial
dwinter
parents:
diff changeset
300 def setTitle(self, title_en, title_de=""):
957bcf42f206 initial
dwinter
parents:
diff changeset
301 """ set the title """
957bcf42f206 initial
dwinter
parents:
diff changeset
302 self.Title = (title_en, title_de)
957bcf42f206 initial
dwinter
parents:
diff changeset
303 # force update of the Properties list in the ZopeDB
957bcf42f206 initial
dwinter
parents:
diff changeset
304 self._p_changed = 1
957bcf42f206 initial
dwinter
parents:
diff changeset
305
957bcf42f206 initial
dwinter
parents:
diff changeset
306 def setDate(self, dateString, dateObject=None):
957bcf42f206 initial
dwinter
parents:
diff changeset
307 """ set the date """
957bcf42f206 initial
dwinter
parents:
diff changeset
308 if dateObject is not None:
957bcf42f206 initial
dwinter
parents:
diff changeset
309 self.Date = dateObject
957bcf42f206 initial
dwinter
parents:
diff changeset
310 else:
957bcf42f206 initial
dwinter
parents:
diff changeset
311 self.Date = self.parseDate(dateString)
957bcf42f206 initial
dwinter
parents:
diff changeset
312
957bcf42f206 initial
dwinter
parents:
diff changeset
313 # force update of the Properties list in the ZopeDB
957bcf42f206 initial
dwinter
parents:
diff changeset
314 self._p_changed = 1
957bcf42f206 initial
dwinter
parents:
diff changeset
315
957bcf42f206 initial
dwinter
parents:
diff changeset
316
957bcf42f206 initial
dwinter
parents:
diff changeset
317 def deleteObject(self,id):
957bcf42f206 initial
dwinter
parents:
diff changeset
318 """ delete an object inside the MPIWGItem """
957bcf42f206 initial
dwinter
parents:
diff changeset
319 if self.hasObject(id):
957bcf42f206 initial
dwinter
parents:
diff changeset
320 self._delObject(id)
957bcf42f206 initial
dwinter
parents:
diff changeset
321
957bcf42f206 initial
dwinter
parents:
diff changeset
322
957bcf42f206 initial
dwinter
parents:
diff changeset
323 def manage_addImage(self, id, file, title='', redirect_url=None, precondition='', content_type='', REQUEST=None):
957bcf42f206 initial
dwinter
parents:
diff changeset
324 """
957bcf42f206 initial
dwinter
parents:
diff changeset
325 Add a new Image object.
957bcf42f206 initial
dwinter
parents:
diff changeset
326 Creates a new Image object 'id' with the contents of 'file'.
957bcf42f206 initial
dwinter
parents:
diff changeset
327 """
957bcf42f206 initial
dwinter
parents:
diff changeset
328 # we use OFS/Image's method without the request
957bcf42f206 initial
dwinter
parents:
diff changeset
329 OFS.Image.manage_addImage(self, id, file, title=title, precondition=precondition, content_type=content_type)
957bcf42f206 initial
dwinter
parents:
diff changeset
330
957bcf42f206 initial
dwinter
parents:
diff changeset
331 # and do our own redirect
957bcf42f206 initial
dwinter
parents:
diff changeset
332 if REQUEST is not None:
957bcf42f206 initial
dwinter
parents:
diff changeset
333 if redirect_url is None:
957bcf42f206 initial
dwinter
parents:
diff changeset
334 redirect_url = 'manage_editItemForm?rnd=%s'%''.join(random.sample("abcdefuvwxyz",8))
957bcf42f206 initial
dwinter
parents:
diff changeset
335
957bcf42f206 initial
dwinter
parents:
diff changeset
336 REQUEST.RESPONSE.redirect(redirect_url)
957bcf42f206 initial
dwinter
parents:
diff changeset
337
957bcf42f206 initial
dwinter
parents:
diff changeset
338 manage_addImageForm = OFS.Image.manage_addImageForm
957bcf42f206 initial
dwinter
parents:
diff changeset
339
957bcf42f206 initial
dwinter
parents:
diff changeset
340 def manage_addFile(self, id, file, title='', redirect_url=None, precondition='', content_type='', REQUEST=None):
957bcf42f206 initial
dwinter
parents:
diff changeset
341 """
957bcf42f206 initial
dwinter
parents:
diff changeset
342 Add a new File object.
957bcf42f206 initial
dwinter
parents:
diff changeset
343 Creates a new File object 'id' with the contents of 'file'.
957bcf42f206 initial
dwinter
parents:
diff changeset
344 """
957bcf42f206 initial
dwinter
parents:
diff changeset
345 # we use OFS/Image's method without the request
957bcf42f206 initial
dwinter
parents:
diff changeset
346 OFS.Image.manage_addFile(self, id, file, title=title, precondition=precondition, content_type=content_type)
957bcf42f206 initial
dwinter
parents:
diff changeset
347
957bcf42f206 initial
dwinter
parents:
diff changeset
348 # and do our own redirect
957bcf42f206 initial
dwinter
parents:
diff changeset
349 if REQUEST is not None:
957bcf42f206 initial
dwinter
parents:
diff changeset
350 if redirect_url is None:
957bcf42f206 initial
dwinter
parents:
diff changeset
351 redirect_url = 'manage_editItemForm?rnd=%s'%''.join(random.sample("abcdefuvwxyz",8))
957bcf42f206 initial
dwinter
parents:
diff changeset
352
957bcf42f206 initial
dwinter
parents:
diff changeset
353 REQUEST.RESPONSE.redirect(redirect_url)
957bcf42f206 initial
dwinter
parents:
diff changeset
354
957bcf42f206 initial
dwinter
parents:
diff changeset
355 manage_addFileForm = OFS.Image.manage_addFileForm
957bcf42f206 initial
dwinter
parents:
diff changeset
356
957bcf42f206 initial
dwinter
parents:
diff changeset
357
957bcf42f206 initial
dwinter
parents:
diff changeset
358
957bcf42f206 initial
dwinter
parents:
diff changeset
359 def manage_editItemForm(self, REQUEST=None):
957bcf42f206 initial
dwinter
parents:
diff changeset
360 """edit item form"""
957bcf42f206 initial
dwinter
parents:
diff changeset
361 # default template is called edit_item_form
957bcf42f206 initial
dwinter
parents:
diff changeset
362 pt = getattr(self, 'edit_item_form', None)
957bcf42f206 initial
dwinter
parents:
diff changeset
363 if pt is not None:
957bcf42f206 initial
dwinter
parents:
diff changeset
364 try:
957bcf42f206 initial
dwinter
parents:
diff changeset
365 return pt()
957bcf42f206 initial
dwinter
parents:
diff changeset
366 except Exception, e:
957bcf42f206 initial
dwinter
parents:
diff changeset
367 logging.error("Problem with edit_item_form: "+str(e))
957bcf42f206 initial
dwinter
parents:
diff changeset
368
957bcf42f206 initial
dwinter
parents:
diff changeset
369 # else use builtin template
957bcf42f206 initial
dwinter
parents:
diff changeset
370 return self.manage_editMPIWGItemForm()
957bcf42f206 initial
dwinter
parents:
diff changeset
371
957bcf42f206 initial
dwinter
parents:
diff changeset
372
957bcf42f206 initial
dwinter
parents:
diff changeset
373
957bcf42f206 initial
dwinter
parents:
diff changeset
374
957bcf42f206 initial
dwinter
parents:
diff changeset
375
957bcf42f206 initial
dwinter
parents:
diff changeset
376
957bcf42f206 initial
dwinter
parents:
diff changeset
377 def getDataFromRecord(self,record,folder):
957bcf42f206 initial
dwinter
parents:
diff changeset
378
957bcf42f206 initial
dwinter
parents:
diff changeset
379 # get predefined properties
957bcf42f206 initial
dwinter
parents:
diff changeset
380 predef = folder.Properties[:]
957bcf42f206 initial
dwinter
parents:
diff changeset
381
957bcf42f206 initial
dwinter
parents:
diff changeset
382
957bcf42f206 initial
dwinter
parents:
diff changeset
383
957bcf42f206 initial
dwinter
parents:
diff changeset
384 for prop in predef:
957bcf42f206 initial
dwinter
parents:
diff changeset
385 self.addProperty(prop)
957bcf42f206 initial
dwinter
parents:
diff changeset
386
957bcf42f206 initial
dwinter
parents:
diff changeset
387 index =0
957bcf42f206 initial
dwinter
parents:
diff changeset
388 for property in self.getPropertyKeys():
957bcf42f206 initial
dwinter
parents:
diff changeset
389 prop = self.Properties[index] # hole alten wert
957bcf42f206 initial
dwinter
parents:
diff changeset
390
957bcf42f206 initial
dwinter
parents:
diff changeset
391 en_value=self.getValueFromRecord(record,property,'en')
957bcf42f206 initial
dwinter
parents:
diff changeset
392 de_value=self.getValueFromRecord(record,property,'de')
957bcf42f206 initial
dwinter
parents:
diff changeset
393 self.Properties[index]=(prop[0],prop[1],en_value,de_value,prop[4],prop[5]) #vordefinierte werte lassen ausser fuer die werte
957bcf42f206 initial
dwinter
parents:
diff changeset
394
957bcf42f206 initial
dwinter
parents:
diff changeset
395
957bcf42f206 initial
dwinter
parents:
diff changeset
396 index+=1
957bcf42f206 initial
dwinter
parents:
diff changeset
397
957bcf42f206 initial
dwinter
parents:
diff changeset
398 transform={'Category':'Reihentitel',
957bcf42f206 initial
dwinter
parents:
diff changeset
399 'Time':'Datum als Text','Presentation':'Titel','Address':'Ort','Notes':'Bemerkungen',
957bcf42f206 initial
dwinter
parents:
diff changeset
400 'Organizers':'Veranstaltet von','Presenter':'Vortragende Person'}
957bcf42f206 initial
dwinter
parents:
diff changeset
401
957bcf42f206 initial
dwinter
parents:
diff changeset
402 def getValueFromRecord(self,record,propertyID,lang):
957bcf42f206 initial
dwinter
parents:
diff changeset
403
957bcf42f206 initial
dwinter
parents:
diff changeset
404 fieldName = ""
957bcf42f206 initial
dwinter
parents:
diff changeset
405 if lang == "en":
957bcf42f206 initial
dwinter
parents:
diff changeset
406 fieldName="EN_"
957bcf42f206 initial
dwinter
parents:
diff changeset
407
957bcf42f206 initial
dwinter
parents:
diff changeset
408
957bcf42f206 initial
dwinter
parents:
diff changeset
409 #fieldName+=self.transform[propertyID]
957bcf42f206 initial
dwinter
parents:
diff changeset
410 fieldName+=propertyID
957bcf42f206 initial
dwinter
parents:
diff changeset
411
957bcf42f206 initial
dwinter
parents:
diff changeset
412 xpathstr = ".//"+NS+"field[@name='%s']"%fieldName
957bcf42f206 initial
dwinter
parents:
diff changeset
413
957bcf42f206 initial
dwinter
parents:
diff changeset
414 val = self.findText(record,xpathstr)
957bcf42f206 initial
dwinter
parents:
diff changeset
415
957bcf42f206 initial
dwinter
parents:
diff changeset
416 if val == "": # leer versuche die andere sprache
957bcf42f206 initial
dwinter
parents:
diff changeset
417 if lang == "en":
957bcf42f206 initial
dwinter
parents:
diff changeset
418 fieldName=""
957bcf42f206 initial
dwinter
parents:
diff changeset
419 else:
957bcf42f206 initial
dwinter
parents:
diff changeset
420 fieldName="EN_"
957bcf42f206 initial
dwinter
parents:
diff changeset
421
957bcf42f206 initial
dwinter
parents:
diff changeset
422 #fieldName+=self.transform[propertyID]
957bcf42f206 initial
dwinter
parents:
diff changeset
423 fieldName+=propertyID
957bcf42f206 initial
dwinter
parents:
diff changeset
424 xpathstr = ".//"+NS+"field[@name='%s']"%fieldName
957bcf42f206 initial
dwinter
parents:
diff changeset
425
957bcf42f206 initial
dwinter
parents:
diff changeset
426 val = self.findText(record,xpathstr)
957bcf42f206 initial
dwinter
parents:
diff changeset
427
957bcf42f206 initial
dwinter
parents:
diff changeset
428 return val
957bcf42f206 initial
dwinter
parents:
diff changeset
429
957bcf42f206 initial
dwinter
parents:
diff changeset
430 def manage_editMPIWGItem(self, formdata=None, REQUEST=None):
957bcf42f206 initial
dwinter
parents:
diff changeset
431 """ """
957bcf42f206 initial
dwinter
parents:
diff changeset
432 if REQUEST is not None:
957bcf42f206 initial
dwinter
parents:
diff changeset
433 formdata = REQUEST.form
957bcf42f206 initial
dwinter
parents:
diff changeset
434
957bcf42f206 initial
dwinter
parents:
diff changeset
435 # update property names and values and weights
957bcf42f206 initial
dwinter
parents:
diff changeset
436 # date,title,category
957bcf42f206 initial
dwinter
parents:
diff changeset
437 try:
957bcf42f206 initial
dwinter
parents:
diff changeset
438 self.Date = self.parseDate(formdata['date'])
957bcf42f206 initial
dwinter
parents:
diff changeset
439 self.Title = (formdata["title_en"],formdata["title_de"])
957bcf42f206 initial
dwinter
parents:
diff changeset
440 self.title = formdata["title_en"]
957bcf42f206 initial
dwinter
parents:
diff changeset
441 except:
957bcf42f206 initial
dwinter
parents:
diff changeset
442 pass
957bcf42f206 initial
dwinter
parents:
diff changeset
443 #self.Category = (formdata["category_en"],formdata["category_de"])
957bcf42f206 initial
dwinter
parents:
diff changeset
444 # custom data
957bcf42f206 initial
dwinter
parents:
diff changeset
445 property_ids = [int(x.split('_')[1]) for x in formdata.keys() if x.endswith('_id')]
957bcf42f206 initial
dwinter
parents:
diff changeset
446 for pid in property_ids:
957bcf42f206 initial
dwinter
parents:
diff changeset
447 if pid < len(self.Properties):
957bcf42f206 initial
dwinter
parents:
diff changeset
448 self.Properties[pid] = (formdata["property_%s_en_key"%pid],
957bcf42f206 initial
dwinter
parents:
diff changeset
449 formdata["property_%s_de_key"%pid],
957bcf42f206 initial
dwinter
parents:
diff changeset
450 formdata["property_%s_en_value"%pid],
957bcf42f206 initial
dwinter
parents:
diff changeset
451 formdata["property_%s_de_value"%pid],
957bcf42f206 initial
dwinter
parents:
diff changeset
452 formdata["property_%s_weight"%pid],
957bcf42f206 initial
dwinter
parents:
diff changeset
453 formdata["property_%s_id"%pid])
957bcf42f206 initial
dwinter
parents:
diff changeset
454
957bcf42f206 initial
dwinter
parents:
diff changeset
455 # delete properties
957bcf42f206 initial
dwinter
parents:
diff changeset
456 # check if properties need to be removed
957bcf42f206 initial
dwinter
parents:
diff changeset
457 # e.g. "del__property_01"
957bcf42f206 initial
dwinter
parents:
diff changeset
458 del_keys = [int(x.split('_')[-1]) for x in formdata.keys() if x.find("del__") == 0 and formdata[x] == "on"]
957bcf42f206 initial
dwinter
parents:
diff changeset
459 del_keys.sort()
957bcf42f206 initial
dwinter
parents:
diff changeset
460 del_keys.reverse()
957bcf42f206 initial
dwinter
parents:
diff changeset
461 for k in del_keys:
957bcf42f206 initial
dwinter
parents:
diff changeset
462 del self.Properties[k]
957bcf42f206 initial
dwinter
parents:
diff changeset
463
957bcf42f206 initial
dwinter
parents:
diff changeset
464 # delete images
957bcf42f206 initial
dwinter
parents:
diff changeset
465 del_keys = [x.split('__')[1] for x in formdata.keys() if x.find("delimg__") == 0 and formdata[x] == "on"]
957bcf42f206 initial
dwinter
parents:
diff changeset
466 for k in del_keys:
957bcf42f206 initial
dwinter
parents:
diff changeset
467 self.deleteObject(k)
957bcf42f206 initial
dwinter
parents:
diff changeset
468
957bcf42f206 initial
dwinter
parents:
diff changeset
469 # delete files
957bcf42f206 initial
dwinter
parents:
diff changeset
470 del_keys = [x.split('__')[1] for x in formdata.keys() if x.find("delfil__") == 0 and formdata[x] == "on"]
957bcf42f206 initial
dwinter
parents:
diff changeset
471 for k in del_keys:
957bcf42f206 initial
dwinter
parents:
diff changeset
472 self.deleteObject(k)
957bcf42f206 initial
dwinter
parents:
diff changeset
473
957bcf42f206 initial
dwinter
parents:
diff changeset
474 # sort
957bcf42f206 initial
dwinter
parents:
diff changeset
475 try:
957bcf42f206 initial
dwinter
parents:
diff changeset
476 self.Properties.sort(lambda a,b: cmp(int(a[4]),int(b[4])) )
957bcf42f206 initial
dwinter
parents:
diff changeset
477 except:
957bcf42f206 initial
dwinter
parents:
diff changeset
478 pass
957bcf42f206 initial
dwinter
parents:
diff changeset
479
957bcf42f206 initial
dwinter
parents:
diff changeset
480 try:
957bcf42f206 initial
dwinter
parents:
diff changeset
481 # add new properties (empty)
957bcf42f206 initial
dwinter
parents:
diff changeset
482 add_new = int(formdata['add_new'])
957bcf42f206 initial
dwinter
parents:
diff changeset
483
957bcf42f206 initial
dwinter
parents:
diff changeset
484 for x in range(add_new):
957bcf42f206 initial
dwinter
parents:
diff changeset
485 self.addProperty()
957bcf42f206 initial
dwinter
parents:
diff changeset
486 except:
957bcf42f206 initial
dwinter
parents:
diff changeset
487 pass
957bcf42f206 initial
dwinter
parents:
diff changeset
488
957bcf42f206 initial
dwinter
parents:
diff changeset
489 # force update of the Properties list in the ZopeDB
957bcf42f206 initial
dwinter
parents:
diff changeset
490 self._p_changed = 1
957bcf42f206 initial
dwinter
parents:
diff changeset
491 self.en.index_html.ZCacheable_invalidate()
957bcf42f206 initial
dwinter
parents:
diff changeset
492
957bcf42f206 initial
dwinter
parents:
diff changeset
493 if REQUEST is not None:
957bcf42f206 initial
dwinter
parents:
diff changeset
494 REQUEST.RESPONSE.redirect('manage_editItemForm?rnd=%s'%''.join(random.sample("abcdefuvwxyz",8)))
957bcf42f206 initial
dwinter
parents:
diff changeset
495
957bcf42f206 initial
dwinter
parents:
diff changeset
496
957bcf42f206 initial
dwinter
parents:
diff changeset
497 manage_editMPIWGItemForm = PageTemplateFile('zpt/editMPIWGItem.pt', globals())
957bcf42f206 initial
dwinter
parents:
diff changeset
498
957bcf42f206 initial
dwinter
parents:
diff changeset
499
957bcf42f206 initial
dwinter
parents:
diff changeset
500 def manage_addMPIWGItem(self,REQUEST=None):
957bcf42f206 initial
dwinter
parents:
diff changeset
501 """ create a new MPIWGItem """
957bcf42f206 initial
dwinter
parents:
diff changeset
502
957bcf42f206 initial
dwinter
parents:
diff changeset
503 id = self.getNewID()
957bcf42f206 initial
dwinter
parents:
diff changeset
504
957bcf42f206 initial
dwinter
parents:
diff changeset
505 # get predefined properties
957bcf42f206 initial
dwinter
parents:
diff changeset
506 predef = self.Properties[:]
957bcf42f206 initial
dwinter
parents:
diff changeset
507
957bcf42f206 initial
dwinter
parents:
diff changeset
508 newinst = MPIWGItem(id)
957bcf42f206 initial
dwinter
parents:
diff changeset
509
957bcf42f206 initial
dwinter
parents:
diff changeset
510 for prop in predef:
957bcf42f206 initial
dwinter
parents:
diff changeset
511 newinst.addProperty(prop)
957bcf42f206 initial
dwinter
parents:
diff changeset
512
957bcf42f206 initial
dwinter
parents:
diff changeset
513 self._setObject(id, newinst)
957bcf42f206 initial
dwinter
parents:
diff changeset
514
957bcf42f206 initial
dwinter
parents:
diff changeset
515 if REQUEST is not None:
957bcf42f206 initial
dwinter
parents:
diff changeset
516 REQUEST.RESPONSE.redirect('%s/manage_editItemForm'%id)
957bcf42f206 initial
dwinter
parents:
diff changeset
517
957bcf42f206 initial
dwinter
parents:
diff changeset
518 return id
957bcf42f206 initial
dwinter
parents:
diff changeset
519
957bcf42f206 initial
dwinter
parents:
diff changeset
520 def manage_addMPIWGItemForm(self, REQUEST):
957bcf42f206 initial
dwinter
parents:
diff changeset
521 """ """
957bcf42f206 initial
dwinter
parents:
diff changeset
522 manage_addMPIWGItem(self,REQUEST)