Mercurial > hg > MPIWGWeb
diff MPIWGProjects_removed.py @ 50:e30a4bd074db
more cleaning up projects.
author | casties |
---|---|
date | Mon, 29 Apr 2013 20:34:17 +0200 |
parents | |
children | 1ed79b33200c |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MPIWGProjects_removed.py Mon Apr 29 20:34:17 2013 +0200 @@ -0,0 +1,241 @@ +# +# removed methods +# +class MPIWGProjects_notused: + + def decode(self, str): + """return unicode object""" + return unicodify(str) + + def isCheckField(self, fieldname): + """return chechfield""" + return (fieldname in checkFields) + + def sortedByPlace(self, metatype): + """find metatype and sort by place""" + def sort(x, y): + return cmp(getattr(x[1], 'place', 0), getattr(y[1], 'place', 0)) + + logging.debug("MPIWGProjects begin: sorted by place: " + metatype) + founds = self.ZopeFind(self, obj_metatypes=[metatype]); + + founds.sort(sort) + logging.debug("MPIWGProjects end: sorted by place: " + metatype) + return founds + + + def harvest_page(self, context=None, mode="normal"): + """seite fuer harvesting fuer die Projektsuche""" + + if not context: + context = self + + if self.isActiveProject() and self.isCurrentVersion(): + templates = self.en.getHarvestCache() + + ext = getattr(self, "harvest_main", None) + if ext: + rendered = getattr(self, ext.getId())() + templates[self.absolute_url()] = rendered + transaction.commit() + return rendered + + + pt = PageTemplateFile(os.path.join(package_home(globals()), 'zpt', 'harvest_main')).__of__(context) + + rendered = pt() + templates[self.absolute_url()] = rendered + transaction.commit() + return rendered + + + + def index_html_old(self, request=True, context=None): + """show homepage""" + + bound_names = {} + + if not context: + context = self + if request: + if self.REQUEST.has_key('date') and self.REQUEST.SESSION.get('MPI_redirected', None) == None: + self.REQUEST.SESSION['MPI_redirected'] = 1 + self.REQUEST.RESPONSE.redirect(self.checkDate(self.REQUEST['date']) + "?date=" + self.REQUEST['date']) + else: + self.REQUEST.SESSION['MPI_redirected'] = None + + # ext=self.ZopeFind(self.aq_parent,obj_ids=["project_main"]) + + + request2 = getattr(self, 'REQUEST', None) + + if request2 is not None: + response = request2.response + if not response.headers.has_key('content-type'): + response.setHeader('content-type', 'text/html') + + security = getSecurityManager() + bound_names['user'] = security.getUser() + + # Retrieve the value from the cache. + keyset = None + if self.ZCacheable_isCachingEnabled(): + + # Prepare a cache key. + keyset = {'here': self, 'params':request2['QUERY_STRING']} + + result = self.ZCacheable_get(keywords=keyset) + + if result is not None: + # Got a cached value. + return result + + pt = getTemplate(self, "project_main") + # Execute the template in a new security context. + security.addContext(self) + + try: + # logging.debug("index_html pt=%s"%repr(pt)) + result = pt.pt_render(extra_context=bound_names) + # logging.debug("index_html result=%s"%repr(result)) + if keyset is not None: + # Store the result in the cache. + self.ZCacheable_set(result, keywords=keyset) + + return result + finally: + security.removeContext(self) + + + + def index_html_old2(self, request=True, context=None): + """show homepage""" + if not context: + context = self + if request: + if self.REQUEST.has_key('date') and self.REQUEST.SESSION.get('MPI_redirected', None) == None: + self.REQUEST.SESSION['MPI_redirected'] = 1 + self.REQUEST.RESPONSE.redirect(self.checkDate(self.REQUEST['date']) + "?date=" + self.REQUEST['date']) + else: + self.REQUEST.SESSION['MPI_redirected'] = None + + # ext=self.ZopeFind(self.aq_parent,obj_ids=["project_main"]) + + ext = getattr(self, "project_main", None) + if ext: + return getattr(self, ext.getId())() + + pt = PageTemplateFile(os.path.join(package_home(globals()), 'zpt', 'project_main')).__of__(context) + + return pt() + + + def no_project(self): + """warnung: project noch nicht existent""" + pt = PageTemplateFile(os.path.join(package_home(globals()), 'zpt', 'no_project')).__of__(self) + return pt() + + + def showImagesOfPage(self, imageUrl=None): + """show Images of project""" + self.getContent('WEB_project_description', filter='yes') # get the content and store image infos into session + pt = PageTemplateFile(os.path.join(package_home(globals()), 'zpt', 'projectImageView.zpt')).__of__(self) + return pt() + + + def show_html(self): + """simple index""" + # return "HI" + pt = PageTemplateFile(os.path.join(package_home(globals()), 'zpt', 'MPIWGProject_index.zpt')).__of__(self) + return pt() + + def getLabel_old(self): + """returns label (or title) of this project""" + l = self.getContent('xdata_07') + if l: + return l + l = self.getContent('WEB_title') + if l: + return l + return self.title + + def getPersonKeyList(self): + """gibt die key Liste der beteiligten Personen zurueck (utf8 codiert)""" + # logging.error("getPersonKeyList:%s"%getattr(self,'responsibleScientistsList',[])) + try: + return [utf8ify(x[1]) for x in getattr(self, 'responsibleScientistsList', [])] + except: + return[] + + + def myCapitalize(self, txt): + """kapitalisiere auch Namen mit -""" + splitted = [x.capitalize() for x in txt.split("-")] + return "-".join(splitted) + + def getNamesOrdered(self, list): + """Sortiert die Liste nach der Reihenfolge in xdata_01""" + + nameList = self.getContent('xdata_01') + if nameList.find(";") > -1: # rate Trenner ist ; + names = nameList.split(";") + else: + names = nameList.split(",") + + self._v_names = [] + for name in names: + self._v_names.append(name.rstrip().lstrip()) + + + def sort(x, y): + try: + return cmp(self._v_names.index(x[0]), self._v_names.index(y[0])) + except: + return 0 + + list.sort(sort) + + return list + + def getWebProject_description(self): + """get description""" + debug = self.REQUEST.cookies.get("MP_debug_code", None) + + if debug and debug == "western": + return """ + <html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + </head> + <body>%s</body> + </html> + """ % self.WEB_project_description[0] + + return """ + <html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + </head> + <body>%s</body> + </html> + """ % self.getContent('WEB_project_description') + + + + def isChecked(self, wert, list): + """check if wert is in ; seperated list""" + + # felder sind manchmnal als liste mit einem element definiert + if type(list) is StringType or UnicodeType: + splitted = list.split(";") + else: + splitted = list[0].split(";") + + splitted = [y.rstrip().lstrip() for y in splitted] + + for x in splitted: + x = re.sub(r"[^A-z ]", "", x) + if (not x == u'') and x in wert: + return 1 + return 0 +