comparison MPIWGProjects_removed.py @ 50:e30a4bd074db

more cleaning up projects.
author casties
date Mon, 29 Apr 2013 20:34:17 +0200
parents
children 1ed79b33200c
comparison
equal deleted inserted replaced
49:e40ff9829108 50:e30a4bd074db
1 #
2 # removed methods
3 #
4 class MPIWGProjects_notused:
5
6 def decode(self, str):
7 """return unicode object"""
8 return unicodify(str)
9
10 def isCheckField(self, fieldname):
11 """return chechfield"""
12 return (fieldname in checkFields)
13
14 def sortedByPlace(self, metatype):
15 """find metatype and sort by place"""
16 def sort(x, y):
17 return cmp(getattr(x[1], 'place', 0), getattr(y[1], 'place', 0))
18
19 logging.debug("MPIWGProjects begin: sorted by place: " + metatype)
20 founds = self.ZopeFind(self, obj_metatypes=[metatype]);
21
22 founds.sort(sort)
23 logging.debug("MPIWGProjects end: sorted by place: " + metatype)
24 return founds
25
26
27 def harvest_page(self, context=None, mode="normal"):
28 """seite fuer harvesting fuer die Projektsuche"""
29
30 if not context:
31 context = self
32
33 if self.isActiveProject() and self.isCurrentVersion():
34 templates = self.en.getHarvestCache()
35
36 ext = getattr(self, "harvest_main", None)
37 if ext:
38 rendered = getattr(self, ext.getId())()
39 templates[self.absolute_url()] = rendered
40 transaction.commit()
41 return rendered
42
43
44 pt = PageTemplateFile(os.path.join(package_home(globals()), 'zpt', 'harvest_main')).__of__(context)
45
46 rendered = pt()
47 templates[self.absolute_url()] = rendered
48 transaction.commit()
49 return rendered
50
51
52
53 def index_html_old(self, request=True, context=None):
54 """show homepage"""
55
56 bound_names = {}
57
58 if not context:
59 context = self
60 if request:
61 if self.REQUEST.has_key('date') and self.REQUEST.SESSION.get('MPI_redirected', None) == None:
62 self.REQUEST.SESSION['MPI_redirected'] = 1
63 self.REQUEST.RESPONSE.redirect(self.checkDate(self.REQUEST['date']) + "?date=" + self.REQUEST['date'])
64 else:
65 self.REQUEST.SESSION['MPI_redirected'] = None
66
67 # ext=self.ZopeFind(self.aq_parent,obj_ids=["project_main"])
68
69
70 request2 = getattr(self, 'REQUEST', None)
71
72 if request2 is not None:
73 response = request2.response
74 if not response.headers.has_key('content-type'):
75 response.setHeader('content-type', 'text/html')
76
77 security = getSecurityManager()
78 bound_names['user'] = security.getUser()
79
80 # Retrieve the value from the cache.
81 keyset = None
82 if self.ZCacheable_isCachingEnabled():
83
84 # Prepare a cache key.
85 keyset = {'here': self, 'params':request2['QUERY_STRING']}
86
87 result = self.ZCacheable_get(keywords=keyset)
88
89 if result is not None:
90 # Got a cached value.
91 return result
92
93 pt = getTemplate(self, "project_main")
94 # Execute the template in a new security context.
95 security.addContext(self)
96
97 try:
98 # logging.debug("index_html pt=%s"%repr(pt))
99 result = pt.pt_render(extra_context=bound_names)
100 # logging.debug("index_html result=%s"%repr(result))
101 if keyset is not None:
102 # Store the result in the cache.
103 self.ZCacheable_set(result, keywords=keyset)
104
105 return result
106 finally:
107 security.removeContext(self)
108
109
110
111 def index_html_old2(self, request=True, context=None):
112 """show homepage"""
113 if not context:
114 context = self
115 if request:
116 if self.REQUEST.has_key('date') and self.REQUEST.SESSION.get('MPI_redirected', None) == None:
117 self.REQUEST.SESSION['MPI_redirected'] = 1
118 self.REQUEST.RESPONSE.redirect(self.checkDate(self.REQUEST['date']) + "?date=" + self.REQUEST['date'])
119 else:
120 self.REQUEST.SESSION['MPI_redirected'] = None
121
122 # ext=self.ZopeFind(self.aq_parent,obj_ids=["project_main"])
123
124 ext = getattr(self, "project_main", None)
125 if ext:
126 return getattr(self, ext.getId())()
127
128 pt = PageTemplateFile(os.path.join(package_home(globals()), 'zpt', 'project_main')).__of__(context)
129
130 return pt()
131
132
133 def no_project(self):
134 """warnung: project noch nicht existent"""
135 pt = PageTemplateFile(os.path.join(package_home(globals()), 'zpt', 'no_project')).__of__(self)
136 return pt()
137
138
139 def showImagesOfPage(self, imageUrl=None):
140 """show Images of project"""
141 self.getContent('WEB_project_description', filter='yes') # get the content and store image infos into session
142 pt = PageTemplateFile(os.path.join(package_home(globals()), 'zpt', 'projectImageView.zpt')).__of__(self)
143 return pt()
144
145
146 def show_html(self):
147 """simple index"""
148 # return "HI"
149 pt = PageTemplateFile(os.path.join(package_home(globals()), 'zpt', 'MPIWGProject_index.zpt')).__of__(self)
150 return pt()
151
152 def getLabel_old(self):
153 """returns label (or title) of this project"""
154 l = self.getContent('xdata_07')
155 if l:
156 return l
157 l = self.getContent('WEB_title')
158 if l:
159 return l
160 return self.title
161
162 def getPersonKeyList(self):
163 """gibt die key Liste der beteiligten Personen zurueck (utf8 codiert)"""
164 # logging.error("getPersonKeyList:%s"%getattr(self,'responsibleScientistsList',[]))
165 try:
166 return [utf8ify(x[1]) for x in getattr(self, 'responsibleScientistsList', [])]
167 except:
168 return[]
169
170
171 def myCapitalize(self, txt):
172 """kapitalisiere auch Namen mit -"""
173 splitted = [x.capitalize() for x in txt.split("-")]
174 return "-".join(splitted)
175
176 def getNamesOrdered(self, list):
177 """Sortiert die Liste nach der Reihenfolge in xdata_01"""
178
179 nameList = self.getContent('xdata_01')
180 if nameList.find(";") > -1: # rate Trenner ist ;
181 names = nameList.split(";")
182 else:
183 names = nameList.split(",")
184
185 self._v_names = []
186 for name in names:
187 self._v_names.append(name.rstrip().lstrip())
188
189
190 def sort(x, y):
191 try:
192 return cmp(self._v_names.index(x[0]), self._v_names.index(y[0]))
193 except:
194 return 0
195
196 list.sort(sort)
197
198 return list
199
200 def getWebProject_description(self):
201 """get description"""
202 debug = self.REQUEST.cookies.get("MP_debug_code", None)
203
204 if debug and debug == "western":
205 return """
206 <html>
207 <head>
208 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
209 </head>
210 <body>%s</body>
211 </html>
212 """ % self.WEB_project_description[0]
213
214 return """
215 <html>
216 <head>
217 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
218 </head>
219 <body>%s</body>
220 </html>
221 """ % self.getContent('WEB_project_description')
222
223
224
225 def isChecked(self, wert, list):
226 """check if wert is in ; seperated list"""
227
228 # felder sind manchmnal als liste mit einem element definiert
229 if type(list) is StringType or UnicodeType:
230 splitted = list.split(";")
231 else:
232 splitted = list[0].split(";")
233
234 splitted = [y.rstrip().lstrip() for y in splitted]
235
236 for x in splitted:
237 x = re.sub(r"[^A-z ]", "", x)
238 if (not x == u'') and x in wert:
239 return 1
240 return 0
241