version 1.30, 2004/09/10 19:59:28
|
version 1.47.2.71, 2007/04/18 10:03:13
|
Line 1
|
Line 1
|
"""This contains the class MPIWG Projects |
"""This contains the class MPIWG Projects |
for organizing and maintaining the different projectspages |
for organizing and maintaining the different project pages |
|
|
""" |
""" |
|
#TODO: mechanismus fur links to personen ueberarbeiten, da jetzt alle e_mails als members auftauchen unabhaenig vom status publish_the_data |
|
#TODO: was passiert wenn aenderungen von jochen im filemaker nicht mit den aenderungen im sql uebereinstimmen |
|
#TODO: in einzelnen projecte steht als pfad auf die bilder noch wwwneu statt www |
|
|
from Products.PageTemplates.PageTemplateFile import PageTemplateFile |
from Products.PageTemplates.PageTemplateFile import PageTemplateFile |
from Products.PageTemplates.PageTemplate import PageTemplate |
from Products.PageTemplates.PageTemplate import PageTemplate |
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate |
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate |
from Products.ZSQLExtend.ZSQLExtend import ZSQLExtendFolder |
from Products.ZSQLExtend.ZSQLExtend import ZSQLExtendFolder |
|
from Products.ZCatalog.CatalogPathAwareness import CatalogAware |
|
from OFS.Image import Image |
|
from Globals import package_home |
import urllib |
import urllib |
import MPIWGStaff |
import MPIWGStaff |
import string |
import string |
import re |
import re |
|
import os |
from types import * |
from types import * |
|
import logging |
import xmlhelper # Methoden zur Verwaltung der projekt xmls |
import xmlhelper # Methoden zur Verwaltung der projekt xml |
from OFS.SimpleItem import SimpleItem |
from OFS.SimpleItem import SimpleItem |
from OFS.Folder import Folder |
from OFS.Folder import Folder |
|
from Products.ZSQLMethods.SQL import SQLConnectionIDs |
|
from AccessControl import ClassSecurityInfo |
from bibliography import * |
from bibliography import * |
|
import time |
|
import xml.dom.minidom |
|
import sys |
|
from Ft.Xml.XPath import Evaluate |
|
from Ft.Xml.XPath.Context import Context |
|
from Ft.Xml.Domlette import NonvalidatingReader,PrettyPrint, Print |
|
from Ft.Xml import EMPTY_NAMESPACE |
|
import copy |
|
import updatePersonalWWW |
|
import MPIWGStaff |
|
|
definedFields=['WEB_title','xdata_01','xdata_02','xdata_03','xdata_04','xdata_05','xdata_06','xdata_07','xdata_08','xdata_09','xdata_10','xdata_11','xdata_12','xdata_13','WEB_project_header','WEB_project_description','WEB_related_pub'] |
definedFields=['WEB_title','xdata_01','xdata_02','xdata_03','xdata_04','xdata_05','xdata_06','xdata_07','xdata_08','xdata_09','xdata_10','xdata_11','xdata_12','xdata_13','WEB_project_header','WEB_project_description','WEB_related_pub'] |
|
|
checkFields = ['xdata_01'] |
checkFields = ['xdata_01'] |
|
|
|
#ersetzt logging |
|
def logger(txt,method,txt2): |
|
"""logging""" |
|
logging.info(txt+ txt2) |
|
|
|
def getTextFromNode(nodename): |
|
nodelist=nodename.childNodes |
|
rc = "" |
|
for node in nodelist: |
|
if node.nodeType == node.TEXT_NODE: |
|
rc = rc + node.data |
|
return rc |
|
|
|
|
|
def sortStopWordsF(self,xo,yo): |
|
if not hasattr(self,'_v_stopWords'): |
|
self._v_stopWords=self.stopwords_en.data.split("\n") |
|
|
|
x=str(xo[1]) |
|
y=str(yo[1]) |
|
|
|
strx=x.split(" ") |
|
stry=y.split(" ") |
|
|
|
for tmp in strx: |
|
if tmp.lower() in self._v_stopWords: |
|
del strx[strx.index(tmp)] |
|
|
|
for tmp in stry: |
|
if tmp.lower() in self._v_stopWords: |
|
del stry[stry.index(tmp)] |
|
|
|
return cmp(" ".join(strx)," ".join(stry)) |
|
|
|
def sortStopWords(self): |
|
return lambda x,y : sortStopWordsF(self,x,y) |
|
|
def sortF(x,y): |
def sortF(x,y): |
try: |
try: |
Line 32 def sortF(x,y):
|
Line 85 def sortF(x,y):
|
try: |
try: |
return cmp(str(x[1]),str(y[1])) |
return cmp(str(x[1]),str(y[1])) |
except: |
except: |
print "error",x[1],y[1] |
|
return 0 |
return 0 |
|
|
def sortI(x,y): |
def sortI(x,y): |
Line 57 def sortI(x,y):
|
Line 110 def sortI(x,y):
|
except: |
except: |
return cmp(x[1],y[1]) |
return cmp(x[1],y[1]) |
|
|
|
class MPIWGLink(SimpleItem): |
|
"""create a symbolic link to another page""" |
|
|
|
meta_type="MPIWGLink" |
|
|
|
def isActiveItem(self): |
|
"""teste ob ausgewaehlt""" |
|
#url1 beim link anstelle von url1, da link jeweils index_html als url hat. |
|
if self.absolute_url()==self.REQUEST['URL1']: |
|
return "aktiv" |
|
else: |
|
return "" |
|
|
|
def __init__(self,id,link,title='',weight=''): |
|
"""init mpiwglink""" |
|
self.id=id |
|
self.link=link |
|
self.title=title |
|
self.weight=weight |
|
|
|
def getObj(self): |
|
"""bekomme original""" |
|
## objpath=self.link.replace("/",".") |
|
## if objpath[0]!=".": |
|
## objpath="."+objpath |
|
|
|
## print objpath |
|
## return eval("self"+objpath) |
|
|
|
|
|
splitted=self.link.lstrip().split("/") |
|
obj=self |
|
for x in splitted: |
|
if not x=="": |
|
obj=getattr(obj,x) |
|
|
|
return obj |
|
|
|
def getWeight(self): |
|
if self.linkWeight and self.linkWeight!="": |
|
return self.linkWeight |
|
else: |
|
return self.getObj().weight |
|
|
|
manage_options=( |
|
{'label':'main config','action':'changeLinkForm'}, |
|
)+SimpleItem.manage_options |
|
|
|
|
|
def changeLinkForm(self): |
|
"""change MPIWG link""" |
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','MPIWGLinkChange.zpt')).__of__(self) |
|
return pt() |
|
|
|
def changeLink(self,link,title,weight,RESPONSE=None): |
|
"""change links""" |
|
self.link=link |
|
self.title=title |
|
self.weight=weight |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage') |
|
|
|
def index_html(self,**argv): |
|
"""index""" |
|
|
|
|
|
|
|
try: |
|
return self.getObj().pt_render(extra_context={'here':self}) |
|
except: |
|
self.REQUEST.RESPONSE.redirect(self.getObj().absolute_url()) |
|
|
|
|
|
|
|
def manage_addMPIWGLinkForm(self): |
|
"""Form for adding link""" |
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt/AddMPIWGLink.zpt')).__of__(self) |
|
return pt() |
|
|
|
def manage_addMPIWGLink(self,id,link,title,weight,RESPONSE=None): |
|
"""add link""" |
|
newObj=MPIWGLink(id,link,title,weight) |
|
|
|
self._setObject(id,newObj) |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
|
class MPIWGTemplate(ZopePageTemplate): |
|
"""Create a layout Template for different purposes""" |
|
|
|
meta_type="MPIWGTemplate" |
|
|
|
manage_options=ZopePageTemplate.manage_options+( |
|
{'label':'Change Weight','action':'changeWeightForm'}, |
|
) |
|
|
|
def changeWeightForm(self): |
|
"""change weight form""" |
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','MPIWGTemplateChangeWeight.zpt')).__of__(self) |
|
return pt() |
|
|
|
def changeWeight(self,weight,RESPONSE=None): |
|
"""change weight""" |
|
self.weight=weight |
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage') |
|
|
|
|
|
def __init__(self, id, text=None, content_type=None,MPIWGType=None): |
|
self.id = str(id) |
|
|
|
|
|
|
|
self.ZBindings_edit(self._default_bindings) |
|
if text is None: |
|
self._default_content_fn = os.path.join(package_home(globals()), |
|
'zpt/MPIWG_%s_template_standard.zpt'%MPIWGType) |
|
text = open(self._default_content_fn).read() |
|
self.pt_edit(text, content_type) |
|
|
|
|
|
"""change form""" |
|
|
|
def isActiveItem(self): |
|
"""teste ob ausgewaehlt""" |
|
if self.absolute_url()==self.REQUEST['URL']: |
|
return "aktiv" |
|
else: |
|
return "" |
|
|
|
def manage_addMPIWGTemplateForm(self): |
|
"""Form for adding""" |
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt/AddMPIWGTemplate.zpt')).__of__(self) |
|
return pt() |
|
|
|
from urllib import quote |
|
|
|
|
|
def manage_addMPIWGTemplate(self, MPIWGType,id, text="",title=None,weight=0,REQUEST=None): |
|
"Add a Page Template with optional file content." |
|
if type(MPIWGType)==StringType: |
|
MPIWGTypes=[MPIWGType] |
|
else: |
|
MPIWGTypes=MPIWGType |
|
|
|
for singleType in MPIWGTypes: |
|
|
|
|
|
if REQUEST is None: |
|
self._setObject(id, MPIWGTemplate(id, text,EchoType=singleType)) |
|
ob = getattr(self, id) |
|
|
|
if title: |
|
ob.pt_setTitle(title) |
|
return ob |
|
else: |
|
file = REQUEST.form.get('file') |
|
headers = getattr(file, 'headers', None) |
|
if headers is None or not file.filename: |
|
zpt = MPIWGTemplate(id,MPIWGType=singleType) |
|
else: |
|
zpt = MPIWGTemplate(id, file, headers.get('content_type')) |
|
|
|
self._setObject(id, zpt) |
|
ob = getattr(self, id) |
|
if title: |
|
ob.pt_setTitle(title) |
|
|
|
try: |
|
u = self.DestinationURL() |
|
except AttributeError: |
|
u = REQUEST['URL1'] |
|
|
|
ob = getattr(self, id) |
|
ob.weight=weight |
|
|
|
REQUEST.RESPONSE.redirect(u+'/manage_main') |
|
return '' |
|
|
|
|
class MPIWGRoot(ZSQLExtendFolder): |
class MPIWGRoot(ZSQLExtendFolder): |
"""Stammordner für den Web-Server""" |
"""Stammordner fuer den Web-Server""" |
|
|
fieldLabels={'WEB_title':'WEB_Title','xdata_01':'Responsible Scientists','xdata_02':'Department', |
fieldLabels={'WEB_title':'WEB_Title','xdata_01':'Responsible Scientists','xdata_02':'Department', |
'xdata_03':'Historical Persons','xdata_04':'Time period', |
'xdata_03':'Historical Persons','xdata_04':'Time period', |
'xdata_05':'Sorting number','xdata_06':'Keywords','xdata_07':'Short title', |
'xdata_05':'Sorting number','xdata_06':'Keywords','xdata_07':'Short title', |
'xdata_08':'Other involved scholars' ,'xdata_09':'Part of','xdata_10':'Covered by', |
'xdata_08':'Other involved scholars' ,'xdata_09':'Disciplines','xdata_10':'Themes', |
'xdata_11':'Object Digitallibrary','xdata_12':'Cooperation partners', |
'xdata_11':'Object Digitallibrary','xdata_12':'Cooperation partners', |
'xdata_13':'Funding institutions','WEB_project_header':'WEB_project_header', |
'xdata_13':'Funding institutions','WEB_project_header':'WEB_project_header', |
'WEB_project_description':'WEB_project_description','WEB_related_pub':'WEB_related_pub'} |
'WEB_project_description':'WEB_project_description','WEB_related_pub':'WEB_related_pub'} |
|
|
folders=['MPIWGProject','Folder'] |
folders=['MPIWGProject','Folder','ECHO_Navigation'] |
meta_type='MPIWGRoot' |
meta_type='MPIWGRoot' |
|
|
|
|
|
def harvestProjects(self): |
|
"""harvest""" |
|
folder="/tmp" |
|
try: |
|
os.mkdir("/tmp/harvest_MPIWG") |
|
except: |
|
pass |
|
founds=self.ZopeFind(self.aq_parent.projects,obj_metatypes=['MPIWGProject'],search_sub=1) |
|
for found in founds: |
|
txt=found[1].harvest_page() |
|
|
|
if txt and (txt != ""): |
|
name=found[0].replace("/","_") |
|
fh=file("/tmp/harvest_MPIWG/"+name,"w") |
|
fh.write(txt) |
|
fh.close() |
|
|
|
def decode(self,str): |
|
"""decoder""" |
|
if not str: |
|
return "" |
|
if type(str) is StringType: |
|
try: |
|
return str.decode('utf-8') |
|
except: |
|
return str.decode('latin-1') |
|
else: |
|
|
|
return str |
|
|
|
|
|
def browserCheck(self): |
|
"""check the browsers request to find out the browser type""" |
|
bt = {} |
|
ua = self.REQUEST.get_header("HTTP_USER_AGENT") |
|
bt['ua'] = ua |
|
bt['isIE'] = False |
|
bt['isN4'] = False |
|
if string.find(ua, 'MSIE') > -1: |
|
bt['isIE'] = True |
|
else: |
|
bt['isN4'] = (string.find(ua, 'Mozilla/4.') > -1) |
|
|
|
try: |
|
nav = ua[string.find(ua, '('):] |
|
ie = string.split(nav, "; ")[1] |
|
if string.find(ie, "MSIE") > -1: |
|
bt['versIE'] = string.split(ie, " ")[1] |
|
except: pass |
|
|
|
bt['isMac'] = string.find(ua, 'Macintosh') > -1 |
|
bt['isWin'] = string.find(ua, 'Windows') > -1 |
|
bt['isIEWin'] = bt['isIE'] and bt['isWin'] |
|
bt['isIEMac'] = bt['isIE'] and bt['isMac'] |
|
bt['staticHTML'] = False |
|
|
|
return bt |
|
|
|
|
|
def versionHeaderEN(self): |
|
"""version header text""" |
|
|
|
date= self.REQUEST.get('date',None) |
|
if date: |
|
txt="""<h2>This pages shows the project which existed at %s</h2>"""%str(date) |
|
return txt |
|
return "" |
|
|
|
def versionHeaderDE(self): |
|
"""version header text""" |
|
date= self.REQUEST.get('date',None) |
|
if date: |
|
txt="""<h2>Auf dieser Seite finden Sie die Projekte mit Stand vom %s</h2>"""%str(date) |
|
return "" |
|
|
|
|
|
def createOrUpdateId_raw(self): |
|
"""create sequence to create ids for bibliography""" |
|
debug=None |
|
#suche groesste existierende id |
|
founds=self.ZSQLQuery("select id from bibliography") |
|
|
|
if founds: |
|
ids=[int(x.id[1:]) for x in founds] |
|
maximum=max(ids) |
|
|
|
id_raw=self.ZSQLQuery("select nextval('id_raw')",debug=debug) |
|
|
|
if id_raw: |
|
self.ZSQLQuery("drop sequence id_raw",debug=debug) |
|
|
|
self.ZSQLQuery("create sequence id_raw start %i"%(maximum+1),debug=debug) |
|
|
|
|
|
def queryLink(self,link): |
|
"""append querystring to the link""" |
|
return "%s?%s"%(link,self.REQUEST.get('QUERY_STRING','')) |
|
|
|
def getKategory(self,url): |
|
"""kategorie""" |
|
splitted=url.split("/") |
|
return splitted[4] |
|
|
|
def generateUrlProject(self,url,project=None): |
|
"""erzeuge aus absoluter url, relative des Projektes""" |
|
if project: |
|
splitted=url.split("/") |
|
length=len(splitted) |
|
short=splitted[length-2:length] |
|
|
|
base=self.REQUEST['URL3']+"/"+"/".join(short) |
|
|
|
else: |
|
findPart=url.find("/projects/") |
|
base=self.REQUEST['URL1']+"/"+url[findPart:] |
|
|
|
|
|
return base |
|
|
|
def isNewCapital(self,text=None,reset=None): |
|
if reset: |
|
self.REQUEST['capital']="A" |
|
return True |
|
else: |
|
if len(text)>0 and not (text[0]==self.REQUEST['capital']): |
|
self.REQUEST['capital']=text[0] |
|
return True |
|
else: |
|
return False |
|
|
|
def subNavStatic(self,obj): |
|
"""subnav" von self""" |
|
def sortWeight(x,y): |
|
x1=int(getattr(x[1],'weight','0')) |
|
y1=int(getattr(y[1],'weight','0')) |
|
return cmp(x1,y1) |
|
|
|
subs=self.ZopeFind(obj,obj_metatypes=['MPIWGTemplate','MPIWGLink']) |
|
subret=[] |
|
|
|
for x in subs: |
|
if not(x[1].title==""): |
|
subret.append(x) |
|
subret.sort(sortWeight) |
|
return subret |
|
|
|
def subNav(self,obj): |
|
"""return subnav elemente""" |
|
def sortWeight(x,y): |
|
x1=int(getattr(x[1],'weight','0')) |
|
y1=int(getattr(y[1],'weight','0')) |
|
return cmp(x1,y1) |
|
#if obj.meta_type in ['MPIWGTemplate','MPIWGLink']: |
|
# id=obj.aq_parent.getId() |
|
#else: |
|
|
|
#id=obj.getId() |
|
|
|
|
|
#suche die zweite ebene |
|
|
|
if not obj.aq_parent.getId() in ['de','en']: |
|
obj=obj.aq_parent |
|
|
|
while not self.ZopeFind(self,obj_ids=[obj.getId()]): |
|
obj=obj.aq_parent |
|
|
|
|
|
if hasattr(self,obj.getId()): |
|
|
|
subs=self.ZopeFind(getattr(self,obj.getId()),obj_metatypes=['MPIWGTemplate','MPIWGLink']) |
|
subret=[] |
|
|
|
for x in subs: |
|
if not(x[1].title==""): |
|
subret.append(x) |
|
subret.sort(sortWeight) |
|
return subret |
|
else: |
|
return None |
|
|
|
def isActive(self,name): |
|
"""teste ob subnavigation aktiv""" |
|
for part in self.REQUEST['URL'].split("/"): |
|
if part==name: |
|
return True |
|
return False |
|
|
|
def getSection(self): |
|
"""returns the current section name""" |
|
root = self.absolute_url() |
|
url = self.REQUEST['URL'] |
|
path = string.replace(url, root, '') |
|
paths = path.split('/') |
|
if len(paths) > 0: |
|
sec = paths[1] |
|
if sec.find('.') < 0: |
|
return sec |
|
else: |
|
return None |
|
return None |
|
|
|
def getSectionStyle(self, name, style=""): |
|
"""returns a string with the given style + '-sel' if the current section == name""" |
|
if self.getSection() == name: |
|
return style + '-sel' |
|
else: |
|
return style |
|
|
|
def MPIWGrootURL(self): |
|
"""returns the URL to the root""" |
|
return self.absolute_url() |
|
|
|
def upDateSQL(self,fileName): |
|
"""updates SQL databases using fm.jar""" |
|
fmJarPath=os.path.join(package_home(globals()), 'updateSQL/fm.jar') |
|
xmlPath=os.path.join(package_home(globals()), "updateSQL/%s"%fileName) |
|
logger("MPIWG Web",logging.INFO,"java -classpath %s -Djava.awt.headless=true Convert %s"%(fmJarPath,xmlPath)) |
|
ret=os.popen("java -classpath %s -Djava.awt.headless=true Convert %s"%(fmJarPath,xmlPath),"r").read() |
|
logger("MPIWG Web",logging.INFO,"result convert: %s"%ret) |
|
return 1 |
|
|
|
def patchProjects(self,RESPONSE): |
|
"""patch""" |
|
projects=self.ZopeFind(self.projects,obj_metatypes=['MPIWGProject']) |
|
for project in projects: |
|
tmp=project[1].WEB_project_description[0].replace("/CD/projects/","")[0:] |
|
setattr(project[1],'WEB_project_description',[tmp[0:]]) |
|
RESPONSE.write("<p>%s</p>\n"%project[0]) |
|
|
def replaceNotEmpty(self,format,field): |
def replaceNotEmpty(self,format,field): |
"""replace not empty""" |
"""replace not empty""" |
if field and (not field==''): |
if field and (not field.lstrip()==''): |
return format%field |
return format%field |
else: |
else: |
return "" |
return "" |
|
|
|
|
|
def isActual(self,project): |
|
"""checke if project is actual""" |
|
actualTime=time.localtime() |
|
obj= project.getObject() |
|
|
|
if getattr(obj,'archiveTime',actualTime)< actualTime: |
|
return False |
|
else: |
|
return True |
|
|
def redirectIndex_html(self,request): |
def redirectIndex_html(self,request): |
#return request['URL1']+'/index_html' |
#return request['URL1']+'/index_html' |
|
|
Line 152 class MPIWGRoot(ZSQLExtendFolder):
|
Line 628 class MPIWGRoot(ZSQLExtendFolder):
|
self.id=id |
self.id=id |
self.title=title |
self.title=title |
|
|
def urlQuote(self,str): |
def removeStopWords(self,xo): |
"""quote""" |
"""remove stop words from xo""" |
return urllib.quote(str) |
if not hasattr(self,'_v_stopWords'): |
|
self._v_stopWords=self.stopwords_en.data.split("\n") |
def urlUnQuote(self,str): |
|
"""quote""" |
|
return urllib.unquote(str) |
|
|
|
def harvestHistoricalPersons(self): |
|
"""erstelle liste aller erwaehnten actors""" |
|
|
|
def normalize(str): |
|
"""loesche fuhrendes space""" |
|
if (len(str)>1) and (str[0]==" "): |
|
ret=str[1:] |
|
else: |
|
ret=str |
|
return ret |
|
|
|
list={} |
|
projects=self.ZopeFind(self.projects,obj_metatypes=['MPIWGProject']) |
|
|
|
for project in projects: |
|
lg=len(project[1].xdata_03[0])-1 |
|
|
|
if (lg>1) and (project[1].xdata_03[0][lg]==";"): |
|
project[1].xdata_03[0]=project[1].xdata_03[0][0:lg] |
|
|
|
|
|
|
|
|
|
try: |
|
if len(project[1].xdata_03[0].split(";"))>1: # guess if separator is ; |
|
for person in project[1].xdata_03[0].split(";"): |
|
personNormal=normalize(person) |
|
if personNormal in list.keys(): |
|
list[urllib.quote(personNormal)][1].append(project[1]) |
|
else: |
|
list[urllib.quote(personNormal)]=(personNormal,[project[1]]) |
|
else: #guess , is sepeator |
|
for person in project[1].xdata_03[0].split(","): |
|
personNormal=normalize(person) |
|
if urllib.quote(personNormal) in list.keys(): |
|
list[urllib.quote(personNormal)][1].append(project[1]) |
|
else: |
|
list[urllib.quote(personNormal)]=(personNormal,[project[1]]) |
|
|
|
except: |
|
print "ERROR",project |
|
|
|
return list |
x=str(xo) |
|
|
def storeHistoricalPersons(self,RESPONSE=None): |
strx=x.split(" ") |
"""store persons""" |
|
self.personDict={} |
|
personDict=self.harvestHistoricalPersons() |
|
for person in personDict.keys(): |
|
for project in personDict[person][1]: |
|
if person in self.personDict.keys(): |
|
self.personDict[person][1].append((project.absolute_url(),project.WEB_title[0],project.xdata_01[0])) |
|
else: |
|
self.personDict[person]=(personDict[person][0],[(project.absolute_url(),project.WEB_title[0],project.xdata_01[0])]) |
|
|
|
if RESPONSE is not None: |
for tmp in strx: |
RESPONSE.redirect("showHistoricalPersons") |
|
|
|
|
if tmp.lower() in self._v_stopWords: |
|
del strx[strx.index(tmp)] |
|
|
def getPersonDict(self,name): |
return " ".join(strx) |
"""name von dict""" |
|
|
|
try: |
def urlQuote(self,str): |
return self.personDict[name][0].encode('utf-8') |
"""quote""" |
except: |
return urllib.quote(str) |
return self.personDict[name][0] |
|
return self.personDict[name][0].decode('latin-1').encode('utf-8') |
|
|
|
|
def urlUnQuote(self,str): |
|
"""quote""" |
|
return urllib.unquote(str) |
|
|
def showHistoricalPersons(self): |
|
"""show persons""" |
|
pt=PageTemplateFile('Products/MPIWGWeb/zpt/showHistoricalPersons').__of__(self) |
|
return pt() |
|
|
|
|
|
def editHistoricalPersonsForm(self): |
def getProjectsByFieldContent(self,fieldName,fieldContentsEntry, date=None): |
"""edit historical persons for consistency""" |
"""gib alle Projekte aus mit Value von field mit fieldName enthaelt ein Element der Liste fieldContents""" |
pt=PageTemplateFile('Products/MPIWGWeb/zpt/editHistoricalPersonsForm').__of__(self) |
def sort(x,y): |
return pt() |
return cmp(x.WEB_title[0],y.WEB_title[0]) |
|
|
def getProjectsByFieldContent(self,fieldName,fieldContentsEntry): |
|
"""gib alle Projekte aus mit Value von field mit fieldName enthält ein Element der Liste fieldContents""" |
|
if type(fieldContentsEntry) is StringType: |
if type(fieldContentsEntry) is StringType: |
fieldContents=[fieldContentsEntry] |
fieldContentsTmp=[fieldContentsEntry] |
else: |
else: |
fieldContents=fieldContentsEntry |
fieldContentsTmp=fieldContentsEntry |
|
|
projects=self.ProjectCatalog({fieldName:string.join(fieldContents,' OR')}) |
fieldContents=[] |
|
for x in fieldContentsTmp: |
|
fieldContents.append(" AND ".join(x.split())) |
|
projects=self.ProjectCatalog({fieldName:string.join(fieldContents,' AND')}) |
#print projects |
#print projects |
return projects |
#ret=[x for x in projects] |
|
ret=[] |
|
for x in projects: |
|
obj=x.getObject() |
|
obj=obj.getActualVersion(date) |
|
if obj and (not getattr(obj,'invisible',None)): |
|
#if not (x in ret): |
|
ret.append(x) |
|
|
|
ret.sort(sort) |
|
return ret |
|
|
def changeMPIWGRootForm(self): |
def changeMPIWGRootForm(self): |
"""edit""" |
"""edit""" |
pt=PageTemplateFile('Products/MPIWGWeb/zpt/changeMPIWGRootForm').__of__(self) |
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','changeMPIWGRootForm')).__of__(self) |
return pt() |
return pt() |
|
|
def changeMPIWGRoot(self,title,disciplineList,themesList,RESPONSE=None): |
def changeMPIWGRoot(self,title,disciplineList,themesList,connection_id,RESPONSE=None): |
"""change""" |
"""change""" |
self.title=title |
self.title=title |
|
self.connection_id=connection_id |
self.disciplineList=disciplineList |
self.disciplineList=disciplineList |
self.themesList=themesList |
self.themesList=themesList |
|
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
def getDisciplineList(self): |
|
"""get disciplines as list""" |
|
return self.disciplineList.split("\n") |
|
|
|
def getThemeList(self): |
|
"""get themes as list""" |
|
return self.themesList.split("\n") |
|
|
|
def test(self): |
|
"""test""" |
|
return self.getProjectsByFieldContent('xdata_09',['biology'])[0].absolute_url |
|
|
|
def getContexts(self,childs=None,parents=None,depth=None): |
|
|
def getContexts(self,childs=None,parents=None,depth=None,date=None,onlyActive=True): |
"""childs alle childs, alle parents""" |
"""childs alle childs, alle parents""" |
ret=[] |
ret=[] |
|
|
if parents: |
if parents: |
splitted=parents.split(".") |
splitted=parents.split(".") |
parentId=string.join(splitted[0:len(splitted)-1],".") |
parentId=string.join(splitted[0:len(splitted)-1],".") |
|
|
for project in self.getProjectFields('xdata_05',sort='int'): |
for project in self.getProjectFields('xdata_05',sort='int',date=date): |
if project[1]==parentId: |
if project[1]==parentId: |
ret.append(project) |
ret.append(project) |
|
|
if childs: |
if childs: |
for project in self.getProjectFields('xdata_05',sort='int'): |
for project in self.getProjectFields('xdata_05',sort='int',date=date): |
searchStr=childs+"(\..*)" |
searchStr=childs+"(\..*)" |
|
|
|
if (onlyActive and project[0].isActiveProject()) or (not onlyActive): |
if re.match(searchStr,project[1]): |
if re.match(searchStr,project[1]): |
|
|
if depth: |
if depth: |
Line 302 class MPIWGRoot(ZSQLExtendFolder):
|
Line 726 class MPIWGRoot(ZSQLExtendFolder):
|
ret.append(project) |
ret.append(project) |
return ret |
return ret |
|
|
def getProjectFields(self,fieldName,folder=None,sort=None): |
def getProjectFields(self,fieldName,date=None,folder=None,sort=None): |
"""getListofFieldNames""" |
"""getListofFieldNames""" |
ret=[] |
ret=[] |
#print "FN",fieldName |
|
if not folder: |
objects=self.ZopeFind(self.projects,obj_metatypes=['MPIWGProject'],search_sub=0) |
folder=self |
|
for object in folder.__dict__: |
|
|
for object in objects: |
obj=getattr(folder,object) |
obj=object[1] |
if hasattr(obj,'meta_type'): |
obj=obj.getActualVersion(date) |
#print obj.meta_type |
if obj and (not getattr(obj,'invisible',None)): |
if obj.meta_type=='MPIWGProject': |
|
if fieldName=="WEB_title_or_short": |
if fieldName=="WEB_title_or_short": |
#print "HI!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
|
#print len(obj.getContent('xdata_07')) |
|
if len(obj.getContent('xdata_07'))<3: # hack weil z.Z. manchmal noch ein Trennzeichen ; oder , im Feld statt leer |
if len(obj.getContent('xdata_07'))<3: # hack weil z.Z. manchmal noch ein Trennzeichen ; oder , im Feld statt leer |
fieldNameTmp="WEB_title" |
fieldNameTmp="WEB_title" |
else: |
else: |
Line 326 class MPIWGRoot(ZSQLExtendFolder):
|
Line 748 class MPIWGRoot(ZSQLExtendFolder):
|
|
|
ret.append((obj,obj.getContent(fieldNameTmp))) |
ret.append((obj,obj.getContent(fieldNameTmp))) |
|
|
if obj.meta_type in self.folders: |
|
|
|
ret += self.getProjectFields(fieldName,obj) |
|
|
|
if sort=="int": |
if sort=="int": |
ret.sort(sortI) |
ret.sort(sortI) |
|
elif sort=="stopWords": |
|
|
|
ret.sort(sortStopWords(self)) |
|
|
else: |
else: |
ret.sort(sortF) |
ret.sort(sortF) |
|
|
Line 340 class MPIWGRoot(ZSQLExtendFolder):
|
Line 763 class MPIWGRoot(ZSQLExtendFolder):
|
def showNewProjects(self): |
def showNewProjects(self): |
projects=[] |
projects=[] |
for objs in self.getProjectFields('WEB_title_or_short'): # Get all Projets |
for objs in self.getProjectFields('WEB_title_or_short'): # Get all Projets |
if objs[0].xdata_05[0] == "": |
if objs[0].xdata_05 and (objs[0].xdata_05[0] == ""): |
|
|
projects.append(objs) |
projects.append(objs) |
|
|
Line 348 class MPIWGRoot(ZSQLExtendFolder):
|
Line 771 class MPIWGRoot(ZSQLExtendFolder):
|
|
|
|
|
manage_options = Folder.manage_options+( |
manage_options = Folder.manage_options+( |
{'label':'Import Persons','action':'importNamesForm'}, |
{'label':'Update personal homepages','action':'updatePersonalwww_html'}, |
|
{'label':'Reindex catalogs','action':'reindexCatalogs'}, |
{'label':'Main config','action':'changeMPIWGRootForm'}, |
{'label':'Main config','action':'changeMPIWGRootForm'}, |
{'label':'Edit Historical Persons','action':'editHistoricalPersonsForm'}, |
{'label':'add e-mails','action':'showNewDBEntries'}, |
{'label':'Store Historical Persons','action':'storeHistoricalPersons'}, |
{'label':'update the institutsbibliography','action':'updateInstitutsbiliography'}, |
|
#{'label':'Edit Historical Persons','action':'editHistoricalPersonsForm'}, |
|
#{'label':'Store Historical Persons','action':'storeHistoricalPersons'}, |
) |
) |
|
|
def importNamesForm(self): |
|
"""Form""" |
def updatePublicationDB(self,personId=None): |
pt=PageTemplateFile('Products/MPIWGWeb/zpt/MPIWGNamesForm.zpt').__of__(self) |
"""updates the publication db, i.e. copy year and type into the main table""" |
|
|
|
if personId: |
|
founds = self.ZSQLInlineSearch(_table="publications",key_main=personId) |
|
else: |
|
founds = self.ZSQLInlineSearch(_table="publications") |
|
|
|
for found in founds: |
|
|
|
if found.id_institutsbibliographie and (not found.id_institutsbibliographie =="") and (not found.id_institutsbibliographie =="0"): |
|
|
|
entries = self.ZSQLInlineSearch(_table="institutsbiblio",id=found.id_institutsbibliographie) |
|
for entry in entries: |
|
self.ZSQLChange(_table='publications',_identify='oid=%s' % found.oid,year=entry.year,referencetype=entry.reference_type) |
|
|
|
if found.id_gen_bib and (not found.id_gen_bib ==""): |
|
entries = self.ZSQLInlineSearch(_table="bibliography",id=found.id_gen_bib) |
|
for entry in entries: |
|
self.ZSQLChange(_table='publications',_identify='oid=%s' % found.oid,year=entry.year,referencetype=entry.reference_type) |
|
|
|
return True |
|
|
|
def showNewDBEntries(self): |
|
"""zeige neue Eintraege in der Datenbank ohne e-mail adressen bzw. fuer die noch kein Object angelegt wurde""" |
|
|
|
qstr="select * from personal_www where web_object_created='no' and not key=''" |
|
res=self.ZSQLQuery(qstr) |
|
|
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','showNewDBEntries.zpt')).__of__(self) |
|
return pt(newEntries=res) |
|
|
|
def createNewStaffObjects(self): |
|
"""create new staff object""" |
|
|
|
memberFolder=getattr(self,'members') |
|
args=self.REQUEST.form |
|
arg_k=args.keys() |
|
arg_k.remove("submit") |
|
ret="" |
|
for key in arg_k: |
|
k=self.urlUnQuote(key) |
|
logging.error("XXXXX %s"%k) |
|
qstr="select * from personal_www where key=%s"%self.ZSQLQuote(k) |
|
res=self.ZSQLQuery(qstr)[0] |
|
if args[key]!="": #email-adresse wurde eingetragen |
|
#create the object |
|
e_mail=args[key] |
|
try: |
|
newObj=MPIWGStaff.MPIWGStaff(e_mail,res.last_name.encode('utf-8'),res.first_name.encode('utf-8'),k) |
|
memberFolder._setObject(e_mail,newObj) |
|
ret+="Created %s \n"%e_mail |
|
created=True |
|
except: |
|
|
|
msg="Cannot create new user %s (%s %s)"%(e_mail,sys.exc_info()[0],sys.exc_info()[1]) |
|
logging.error(msg) |
|
ret+=msg+"\n" |
|
created=False |
|
|
|
if created: |
|
qstr="update personal_www set web_object_created='yes',e_mail='%s' where key=%s"%(e_mail,self.ZSQLQuote(k)) |
|
self.ZSQLQuery(qstr) |
|
return ret |
|
|
|
|
|
def generateNewPersonEntry(self,data): |
|
"""generate a new person entry for data, neue personen werden zunaechst nur in der datenbank angelegt """ |
|
|
|
#memberFolder=getattr(self,'members') |
|
#create the object |
|
|
|
# try: |
|
# newObj=MPIWGStaff.MPIWGStaff(urllib.quote(data['key']),data['last_name'].encode('utf-8'),data['first_name'].encode('utf-8')) |
|
# memberFolder._setObject(urllib.quote(data['key']),newObj) |
|
# except: |
|
# return False, "Cannot create new user %s (%s %s)"%(data['key'],sys.exc_info()[0],sys.exc_info()[1]) |
|
# |
|
|
|
#create the new entry in the database |
|
|
|
|
|
result,msg=MPIWGStaff.createNewDBEntry(self,data['publish_the_data'],data['key'],data['last_name'], |
|
data['first_name'],data['title'],data['status'],"", |
|
"",data['date_from'],data['date_to'], |
|
data['department'],data['home_inst'],data['funded_by'], |
|
data['e_mail2'],data['current_work'],"yes",data['date_stay_at_mpiwg'],data['group'],"no",data['current_work']) |
|
|
|
return result,msg |
|
|
|
def updatePersonEntry(self,data,ignoreEntries=[]): |
|
"""update an person entry from data. but ignore all fields in ignore Entries""" |
|
|
|
ignoreEntries.append('current_work') # TODO:updatecurrent work |
|
|
|
if data['date_to']=="": # wenn date_to leer |
|
data['date_to']="date_none" |
|
|
|
if data['date_from']=="": # wenn date_fromleer |
|
data['date_from']="date_none" |
|
msg="" |
|
|
|
|
|
#eintragen |
|
|
|
columns=data.keys() |
|
for x in ignoreEntries: |
|
columns.remove(x) |
|
|
|
|
|
|
|
insert=[] |
|
for key in columns: |
|
if data[key]=="date_none": # date_none eintrag wird zu null uebersetzt |
|
insert.append('%s=null'%key) |
|
else: |
|
insert.append(""" "%s"=%s"""%(key,self.ZSQLQuote(data[key]))) |
|
|
|
insertStr=",".join(insert) |
|
queryStr="update personal_www SET %s where key='%s'"%(insertStr,data['key']) |
|
self.ZSQLQuery("SET DATESTYLE TO 'German'") |
|
self.ZSQLQuery(queryStr) |
|
|
|
#currentwork |
|
#if not (txt==""): |
|
# queryStr="INSERT INTO current_work (id_main,current,publish) VALUES ('%s','%s','%s')"%(id,txt,txt_p) |
|
# |
|
# self.ZSQLQuery(queryStr) |
|
|
|
return True,msg |
|
def updatePersonalwww_doIt(self): |
|
"""do the update""" |
|
args=self.REQUEST.form |
|
resultSet=self.REQUEST.SESSION['personal_www']['resultSet'] |
|
news=self.REQUEST.SESSION['personal_www']['news'] |
|
conflicts=self.REQUEST.SESSION['personal_www']['conflicts'] |
|
ret="<html><body>" |
|
# generate the new entry |
|
|
|
if news and (len(news)>0): |
|
ret+="<h2>HinzugefŸgt</h2>" |
|
ret+="<p>NeueintrŠge erscheinen erst auf der Homepage, wenn ihnen eine e-mail Adresse zugeordnet wurde.</p>" |
|
ret+="<ul>" |
|
for new in news: |
|
|
|
if args.has_key(self.urlQuote(new.encode('utf-8'))): # entry was selected |
|
result,msg=self.generateNewPersonEntry(resultSet[new]) |
|
if not result: |
|
logging.error("Error (generateNewPersonEntry) %s"%msg) |
|
ret+="<li>ERROR: %s %s"%(new.encode('utf-8'),msg) |
|
else: |
|
ret+="<li>OK: %s"%(new.encode('utf-8')) |
|
if news and (len(news)>0): |
|
ret+="<p>NeueintrŠge erscheinen erst auf der Homepage, wenn ihnen eine e-mail Adresse zugeordnet wurde.</p>" |
|
ret+="</ul>" |
|
|
|
# update |
|
|
|
if len(conflicts.keys())>0: |
|
ret+="<h2>Bei €nderung belassen</h2>" |
|
ret+="<p>Bitte die Filemaker-db entsprehchend Šndern</p>" |
|
|
|
|
|
for conflict in conflicts.keys(): |
|
ignoreEntries=[] |
|
displayIgnored=[] |
|
for cf in conflicts[conflict]: |
|
if args[conflict.encode('utf-8')+'_'+cf[0]]=="stored": #use the stored one |
|
ignoreEntries.append(cf[0]) #so ignore field cf[0] |
|
displayIgnored.append(cf) |
|
if len(displayIgnored)>0: |
|
ret+="<h3>%s</h3>"%conflict.encode('utf-8') |
|
|
|
ret+="<table border='1'>" |
|
for iE in displayIgnored: |
|
ret+="<tr><td>%s</td><td>%s</td><td>%s</td>"%(iE[0].encode('utf-8'),iE[1].encode('utf-8'),iE[2].encode('utf-8')) |
|
ret+="</tabel>" |
|
|
|
self.updatePersonEntry(resultSet[conflict],ignoreEntries=ignoreEntries) |
|
|
|
return ret+"</body></html>" |
|
|
|
def updateInstitutsbiliography(self): |
|
"""update the Institutsbibliogrpahy""" |
|
self.upDateSQL('personalwww.xml') |
|
return "<html><body>DONE</body></html>" |
|
def updatePersonalwww_html(self): |
|
"""update form for the homepages web form""" |
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','updatePersonalwww.zpt')).__of__(self) |
return pt() |
return pt() |
|
|
def importNames(self,fileupload,folderName,RESPONSE=None): |
def updatePersonalwww(self,uploadfile): |
"""import komma-sep list email,lastName,firstName""" |
"""update personalwww |
project=getattr(self,folderName) |
@param uploadfile: file handle auf das file |
load=fileupload.read() |
""" |
|
dsn="dbname=personalwww" |
|
resultSet=updatePersonalWWW.importFMPXML(uploadfile) |
|
news,conflicts=updatePersonalWWW.checkImport(dsn, resultSet) |
|
|
|
self.REQUEST.SESSION['personal_www']={} |
|
self.REQUEST.SESSION['personal_www']['resultSet']=resultSet |
|
self.REQUEST.SESSION['personal_www']['news']=news |
|
self.REQUEST.SESSION['personal_www']['conflicts']=conflicts |
|
|
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','updatePersonalwww_check.zpt')).__of__(self) |
|
return pt() |
|
|
for line in load.split('\r'): |
|
|
|
|
|
splitted=line.split(",") |
def reindexCatalogs(self,RESPONSE=None): |
# print splitted |
"""reindex members and project catalog""" |
|
|
if not (splitted[0]==""): |
|
newObj=MPIWGStaff.MPIWGStaff(splitted[0],splitted[1],splitted[2]) |
|
|
|
try: |
try: |
project._setObject(splitted[0],newObj) |
self.MembersCatalog.manage_catalogReindex(self.REQUEST,RESPONSE,self.REQUEST['URL1']) |
#print "done:",splitted[0] |
self.ProjectCatalog.manage_catalogReindex(self.REQUEST,RESPONSE,self.REQUEST['URL1']) |
except: |
except: |
print "not done:",splitted[0] |
logger("MPIWG Root (updatehomepage)",logging.WARNING," %s %s"%sys.exc_info()[:2]) |
|
|
if RESPONSE is not None: |
|
|
|
|
|
|
|
|
if RESPONSE: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
|
|
|
|
|
|
def getAllMembers(self): |
def getAllMembers(self): |
"""give list of all members""" |
#ret=[] |
ret=[] |
|
|
|
#for x in self.members.objectValues('MPIWGStaff'): |
results=self.MembersCatalog({'isPublished':True}) |
#print x.title |
|
# ret.append(x.title.decode('utf-8')) |
|
|
|
for x in self.ZopeFind(self.members,obj_metatypes=['MPIWGStaff']): |
ret=[", ".join([proj.lastName, proj.firstName]).decode('utf-8') for proj in results] |
ret.append(x[1].title.decode('utf-8')) |
|
|
|
ret.sort() |
ret.sort() |
#print ret |
|
|
|
return ret |
return ret |
|
|
def printAllMembers(self): |
def printAllMembers(self): |
"""prin""" |
"""print""" |
members=self.getAllMembers() |
members=self.getAllMembers() |
ret="" |
ret="" |
for x in members: |
for x in members: |
Line 415 class MPIWGRoot(ZSQLExtendFolder):
|
Line 1036 class MPIWGRoot(ZSQLExtendFolder):
|
return entry |
return entry |
|
|
|
|
def getTree(self): |
def getTree(self,dep=None,date=None,onlyActive=None): |
"""generate Tree from project list""" |
"""generate Tree from project list""" |
|
|
returnList=[] |
returnList=[] |
for project in self.getProjectFields('xdata_05',sort="int"): # get Projects sorted by xdata_05 |
for project in self.getProjectFields('xdata_05',sort="int",date=date): # get Projects sorted by xdata_05 |
|
|
for idNr in project[1].split(";"): # more than one number |
for idNr in project[1].split(";"): # more than one number |
if not idNr=="": |
if not idNr=="": |
splittedId=idNr.split(".") |
splittedId=idNr.split(".") |
Line 427 class MPIWGRoot(ZSQLExtendFolder):
|
Line 1050 class MPIWGRoot(ZSQLExtendFolder):
|
#title=project[0].WEB_title |
#title=project[0].WEB_title |
title=[project[0].getContent('WEB_title')] |
title=[project[0].getContent('WEB_title')] |
#print title |
#print title |
returnList.append((depth,nr,title,project[0])) |
|
|
|
return returnList |
|
|
|
def formatElementForOverview(self,element): |
if idNr[0]=="x": # kompatibilitaet mit alter Konvention, x vor der Nummer macht project inactive |
"""format the element for output in overview""" |
project[0].setActiveFlag(False) |
if element[0]==1: #department |
|
#print element[3].getContent('xdata_05') |
|
if element[3].getContent('xdata_05') == "4": |
|
return """<h2><a href="%s">Ind. Research Group I: %s</a></h2>"""%(element[3].absolute_url()+"/index.html",element[3].getContent('WEB_title')) |
|
if element[3].getContent('xdata_05') == "5": |
|
return """<h2><a href="%s">Ind. Research Group II: %s</a></h2>"""%(element[3].absolute_url()+"/index.html",element[3].getContent('WEB_title')) |
|
|
|
return """<h2><a href="%s">Department %s: %s</a></h2>"""%(element[3].absolute_url()+"/index.html",element[3].getContent('xdata_05'),element[3].getContent('WEB_title')) |
if (not dep) or (idNr[0]==dep): #falls dep gesetzt ist nur dieses hinzufuegen. |
|
if onlyActive and project[0].isActiveProject(): #nur active projekte |
|
returnList.append((depth,nr,title,project[0])) |
|
elif not onlyActive: |
|
returnList.append((depth,nr,title,project[0])) |
|
return returnList |
|
|
elif element[0]==2: #mainprojects |
|
return """<h3><a href="%s">%s</a></h3><p>"""%(element[3].absolute_url()+"/index.html",element[3].getContent('WEB_title')) |
|
|
|
elif element[0]==3: |
|
return """<p class="p_noindent"><a href="%s">%s</a></p>"""%(element[3].absolute_url()+"/index.html",element[3].getContent('WEB_title')) |
|
|
|
def changePosition(self,treeId,select,RESPONSE=None): |
def changePosition(self,treeId,select,RESPONSE=None): |
"""Change Postion Entry""" |
"""Change Postion Entry""" |
Line 488 class MPIWGRoot(ZSQLExtendFolder):
|
Line 1103 class MPIWGRoot(ZSQLExtendFolder):
|
|
|
|
|
for idNr in form.keys(): |
for idNr in form.keys(): |
|
|
|
splitted=idNr.split('_') |
|
|
|
if len(splitted)==1: # name des Feldes = idNr, dann Aendere id_nr |
|
if not (fields[int(idNr)][3].xdata_05==form[idNr]): |
fields[int(idNr)][3].xdata_05=form[idNr] |
fields[int(idNr)][3].xdata_05=form[idNr] |
|
fields[int(idNr)][3].copyObjectToArchive() |
|
|
|
if form.has_key(idNr+'_active'): # active flag is set |
|
|
|
fields[int(splitted[0])][3].setActiveFlag(True) |
|
else: |
|
|
|
fields[int(splitted[0])][3].setActiveFlag(False) |
|
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('showTree') |
RESPONSE.redirect('showTree') |
Line 537 class MPIWGRoot(ZSQLExtendFolder):
|
Line 1163 class MPIWGRoot(ZSQLExtendFolder):
|
return string.join(ret,";") |
return string.join(ret,";") |
|
|
|
|
|
def getMembersFromList(self,list): |
|
"""get member names from person full text list""" |
|
memberlist=[] |
|
persons=list.split(";") |
|
for person in persons: |
|
if len(person)>1: #nicht nur Trennzeichen |
|
splitted=person.split(",") |
|
if len(splitted)==1: |
|
splitted=person.lstrip().rstrip().split(" ") |
|
splittedNew=[re.sub(r'\s(.*)','$1',split) for split in splitted] |
|
if splittedNew[0]=='': |
|
del splittedNew[0] |
|
search=string.join(splittedNew,' AND ') |
|
|
|
if not search=='': |
|
try: |
|
member=self.MembersCatalog({'title':search}) |
|
except: |
|
member=None |
|
|
|
if member and (member[0].getObject().isPublished()): |
|
if person =="Otto Sibum" : person="H. Otto Sibum" |
|
if person =="Norton Wise" : person="M. Norton Wise" |
|
#memberlist.append("<a href=%s >%s</a>"%(member[0].absolute_url,person.encode('utf-8'))) |
|
memberlist.append((person, member[0].getObject().getId())) |
|
else: |
|
#memberlist.append("%s"%person.encode('utf-8')) |
|
memberlist.append((person,None)) |
|
return memberlist |
|
|
def getUrlFromPerson(self,list): |
def getUrlFromPerson(self,list): |
"""get urls to person list""" |
"""get urls to person list""" |
ret=[] |
ret=[] |
Line 559 class MPIWGRoot(ZSQLExtendFolder):
|
Line 1215 class MPIWGRoot(ZSQLExtendFolder):
|
except: |
except: |
proj=None |
proj=None |
|
|
if proj: |
if proj and (proj[0].getObject().isPublished()): |
|
if person =="Otto Sibum" : person="H. Otto Sibum" |
|
if person =="Norton Wise" : person="M. Norton Wise" |
#ret.append("<a href=%s >%s</a>"%(proj[0].absolute_url,person.encode('utf-8'))) |
#ret.append("<a href=%s >%s</a>"%(proj[0].absolute_url,person.encode('utf-8'))) |
ret.append("<a href=%s >%s</a>"%(proj[0].absolute_url+"/index.html",person)) |
if self.MPIWGrootURL().split("/")[-1]=='en': |
|
tmpPath="/en/staff/members/" |
|
else: |
|
tmpPath="/de/mitarbeiter/members/" |
|
ret.append("<a href=%s >%s</a>"%(tmpPath+proj[0].getObject().getId()+"/index.html",person)) |
else: |
else: |
#ret.append("%s"%person.encode('utf-8')) |
#ret.append("%s"%person.encode('utf-8')) |
ret.append("%s"%person) |
ret.append("%s"%person) |
return string.join(ret,";") |
return string.join(ret,";") |
|
|
def getProjectsOfMembers(self): |
def getProjectsOfMembers(self,date=None): |
"""give tuple member /projects""" |
"""give tuple member /projects""" |
ret=[] |
ret=[] |
members=self.getAllMembers() |
members=self.getAllMembers() |
|
|
#return str(members) |
#return str(members) |
for x in members: |
for x in members: |
ret+=self.getProjectsOfMember(name=x) |
|
|
ret+=self.getProjectsOfMember(name=x,date=date) |
|
|
return ret |
return ret |
|
|
def getProjectsOfMember(self,name=None,email=None): |
def getProjectsOfMember(self,name=None,key=None,date=None): |
"""get project of a member""" |
"""get projects of a member |
|
@param name: (optional)Vorname + Nachname |
|
@param key: (optional) Key zur Idenfikation des Benutzer |
|
@param date: (optional) Version die zum Zeitpunkt date gueltig war |
|
""" |
|
# TODO: Die ganze Lšsung |
def sortP(x,y): |
def sortP(x,y): |
"""sort by sorting number""" |
"""sort by sorting number""" |
#print x.xdata_05,y.xdata_05 |
#print x.xdata_05,y.xdata_05 |
Line 586 class MPIWGRoot(ZSQLExtendFolder):
|
Line 1255 class MPIWGRoot(ZSQLExtendFolder):
|
|
|
|
|
ret=[] |
ret=[] |
splitNeu=[] |
logging.error("XXXXXXXXXXXXXXXXX") |
if email: |
if key: |
members=self.ZopeFind(self.members,obj_metatypes=['MPIWGStaff'],obj_ids=[email]) |
|
name = members[0][1].title.decode('utf-8') |
#members=self.ZopeFind(self.members,obj_metatypes=['MPIWGStaff'],obj_ids=[email],search_sub=1) |
|
members=self.MembersCatalog({'getKey':key}) |
|
if len(members)==0: |
|
return ret |
|
|
|
splitted = [members[0].lastName,members[0].firstName] |
|
|
|
elif name: |
|
|
|
splitted=name.split(",") |
|
else: |
|
return ret # name oder key mussen definiert sein |
|
|
y=name |
|
splitted=y.split(",") |
|
#XXXX |
#XXXX |
splitNeu=["\'"+splitted[1]+" "+splitted[0]+"\'"] |
splitNeu=["\'"+splitted[1]+" "+splitted[0]+"\'"] |
|
|
Line 601 class MPIWGRoot(ZSQLExtendFolder):
|
Line 1279 class MPIWGRoot(ZSQLExtendFolder):
|
search=string.join(splitNeu,' AND ') |
search=string.join(splitNeu,' AND ') |
|
|
proj=self.ProjectCatalog({'xdata_01':search}) |
proj=self.ProjectCatalog({'xdata_01':search}) |
|
logging.error("XXXXXXXXXXX %s"%proj) |
if proj: |
if proj: |
proj2=[] |
proj2=[] |
for x in proj: |
for x in proj: |
|
if (not getattr(x.getObject(),'invisible',None)) and (getattr(x.getObject(),'archiveTime','')==''): |
|
# furchtbarer hack um sicher zustellen dass christoph hoffmann nicht mit Dieter Hoffmann verwechselt wird. |
if not((splitted[1]==" Christoph") and (splitted[0]=="Hoffmann") and (str(x.WEB_title).find('Einstein')>0)): |
if not((splitted[1]==" Christoph") and (splitted[0]=="Hoffmann") and (str(x.WEB_title).find('Einstein')>0)): |
|
|
#print repr(splitted[1]),repr(splitted[0]),repr(x.WEB_title) |
|
proj2.append(x) |
proj2.append(x) |
# proj2.sort(sortP) |
|
# ret.append((y,proj2)) |
|
else: |
else: |
proj2=[] |
proj2=[] |
|
|
Line 619 class MPIWGRoot(ZSQLExtendFolder):
|
Line 1295 class MPIWGRoot(ZSQLExtendFolder):
|
if proj: |
if proj: |
names=[x.WEB_title for x in proj] |
names=[x.WEB_title for x in proj] |
for x in proj: |
for x in proj: |
if not x.WEB_title in names: |
|
|
if (not x.WEB_title in names) and (getattr(x.getObject(),'archiveTime','')==''): |
proj2.append(x) |
proj2.append(x) |
|
|
|
|
proj2.sort(sortP) |
proj2.sort(sortP) |
|
|
if len(proj2)>0: |
if len(proj2)>0: |
ret.append((y,proj2)) |
ret.append((name,proj2)) |
|
|
return ret |
return ret |
|
|
Line 641 class MPIWGRoot(ZSQLExtendFolder):
|
Line 1318 class MPIWGRoot(ZSQLExtendFolder):
|
if splittedNew[0]=='': |
if splittedNew[0]=='': |
del splittedNew[0] |
del splittedNew[0] |
search=string.join(splittedNew,' AND ') |
search=string.join(splittedNew,' AND ') |
|
|
if not search=='': |
if not search=='': |
proj=self.MembersCatalog({'title':search}) |
proj=self.MembersCatalog({'title':search}) |
|
|
Line 671 class MPIWGRoot(ZSQLExtendFolder):
|
Line 1349 class MPIWGRoot(ZSQLExtendFolder):
|
## objs.append((obj,lastName+", "+firstName)) |
## objs.append((obj,lastName+", "+firstName)) |
|
|
|
|
return objs |
## return objs |
|
|
|
|
def personCheck(self,names): |
def personCheck(self,names): |
Line 704 class MPIWGRoot(ZSQLExtendFolder):
|
Line 1382 class MPIWGRoot(ZSQLExtendFolder):
|
return (fieldname in checkFields) |
return (fieldname in checkFields) |
|
|
|
|
|
def generateNameIndex(self): |
|
"""erzeuge einen index verwendeter personen""" |
|
import psycopg |
|
o = psycopg.connect('dbname=authorities user=dwinter password=3333',serialize=0) |
|
results={} |
|
print self.fulltext.historicalNames.items() |
|
for nameItem in self.fulltext.historicalNames.items(): #gehe durch alle namen des lexikons |
|
|
|
c = o.cursor() |
|
name=nameItem[0] |
|
print "check",name |
|
c.execute("select lastname,firstname from persons where lower(lastname) = '%s'"%quote(name)) |
|
tmpres=c.fetchall() |
|
firstnames=[result[1] for result in tmpres] # find all firstnames |
|
if tmpres: |
|
lastname=tmpres[0][0] |
|
|
|
for found in self.fulltext({'names':name}): |
|
if found.getObject().isActual(): |
|
for nh in found.getObject().getGetNeighbourhood(name, length=50,tagging=False): #hole umgebung |
|
#schaue nun ob der vorname hinter oder vor dem name ist |
|
position=nh.find(lastname) |
|
# vorher |
|
#print "NH",nh |
|
bevorS=nh[0:position].split() |
|
#print "BV",bevorS |
|
if len(bevorS)>1: |
|
try: |
|
bevor=[bevorS[-1],bevorS[-2]] |
|
except: |
|
bevor=[bevorS[0]] |
|
else: |
|
bevor=[] |
|
#nachher |
|
behindS= re.split("[,|;| ]",nh[position:]) |
|
#print "BH",behindS |
|
if len(behindS)>2: |
|
try: |
|
behind=behindS[1:3] |
|
except: |
|
behind=[bevorS[1]] |
|
else: |
|
behind=[] |
|
for firstname in firstnames: |
|
if firstname in bevor+behind: #Namen wie mit Adelspraedikaten werden so erstmal nich gefunden |
|
id="%s,%s"%(lastname,firstname) |
|
if not results.has_key(id): |
|
results[id]=[] |
|
objId=found.getObject().getId() |
|
if not (objId in results[id]): |
|
print "d %s for %s"%(id,objId) |
|
results[id].append(objId) |
|
self.nameIndex=results |
|
return results |
|
|
|
def editNameIndexHTML(self): |
|
"""edit the name index""" |
|
if not hasattr(self,'nameIndexEdited'): # falls editierter index noch nicht existiert, kopiere automatisch erstellten |
|
self.nameIndexEdited=copy.copy(self.nameIndex) |
|
print "huh" |
|
#self.nameIndexEdited=copy.copy(self.nameIndex) |
|
#print self.nameIndexEdited |
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editHistoricalNames.zpt')).__of__(self) |
|
return pt() |
|
|
|
def getNamesInProject(self,projectId): |
|
"""get all names ofnameIndexEdited which are references in projec with projectId""" |
|
|
|
ret=[] |
|
for name in self.nameIndexEdited.keys(): |
|
if projectId in self.nameIndexEdited[name]: |
|
ret.append(name) |
|
|
|
return ret |
|
|
|
def editNameIndex(self,RESPONSE=None,name=None,occurrances=None,submit=None): |
|
"""edit the index""" |
|
nI=self.nameIndexEdited # mI introduced to make sure that changes to nameIndexEdited are know to ZODB |
|
if submit=="delete": |
|
|
|
|
|
dh=getattr(self,'deletedHistoricalNames',{}) |
|
|
|
if type(dh) is ListType: |
|
dh={} |
|
if not dh.has_key(name): |
|
dh[name]=occurrances.split("\n") |
|
else: |
|
dh[name]+=occurrances.split("\n") |
|
|
|
self.deletedHistoricalNames=dh |
|
|
|
del self.nameIndexEdited[name] |
|
|
|
|
|
elif (submit=="change"): |
|
|
|
nI[name]=occurrances.split("\n")[0:] |
|
|
|
elif (submit=="add"): |
|
if not nI.has_key(name): |
|
nI[name]=occurrances.split("\n") |
|
else: |
|
nI[name]+=occurrances.split("\n") |
|
|
|
self.nameIndexEdited=nI |
|
|
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('editNameIndexHTML') |
|
|
|
|
|
|
|
def restoreIndex(self): |
|
"""restore""" |
|
self.nameIndexEdited=self.nameIndex |
|
return "done" |
|
|
|
|
|
|
def manage_addMPIWGRootForm(self): |
def manage_addMPIWGRootForm(self): |
"""form for adding the root""" |
"""form for adding the root""" |
pt=PageTemplateFile('Products/MPIWGWeb/zpt/addMPIWGRootForm.zpt').__of__(self) |
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addMPIWGRootForm.zpt')).__of__(self) |
return pt() |
return pt() |
|
|
def manage_addMPIWGRoot(self,id,title,RESPONSE=None): |
def manage_addMPIWGRoot(self,id,title,connection_id="",RESPONSE=None): |
"""add a root folder""" |
"""add a root folder""" |
newObj=MPIWGRoot(id,title) |
newObj=MPIWGRoot(id,title) |
self._setObject(id,newObj) |
self._setObject(id,newObj) |
|
ob=getattr(self,id) |
|
setattr(ob,'connection_id',connection_id) |
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
|
|
class MPIWGProject(Folder): |
class MPIWGProject_publication(SimpleItem): |
|
"""publications object fuer project""" |
|
|
|
meta_type="MPIWGProject_publication" |
|
|
|
def editPublication(self,text=None,RESPONSE=None): |
|
"""edit a publication""" |
|
|
|
if (not text): |
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','edit_publicationForm.zpt')).__of__(self) |
|
return pt() |
|
|
|
|
|
self.text=text[0:] |
|
|
|
if RESPONSE: |
|
RESPONSE.redirect("../managePublications") |
|
|
|
class MPIWGProject_image(Image): |
|
"""Images for Projects""" |
|
|
|
meta_type="MPIWGProject_image" |
|
|
|
def showImage(self,imageUrl=None): |
|
"""show Images at an extra page""" |
|
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 editImage(self,file=None,caption=None,RESPONSE=None): |
|
"""edit the Image""" |
|
if (not file) and (not caption): |
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','edit_imageForm.zpt')).__of__(self) |
|
return pt() |
|
|
|
if file and (not file.filename.lstrip().rstrip()==""): |
|
self.manage_upload(file) |
|
|
|
if caption: |
|
self.caption=caption[0:] |
|
|
|
if RESPONSE: |
|
RESPONSE.redirect("../manageImages") |
|
|
|
class MPIWGProject(CatalogAware,Folder): |
"""Class for Projects""" |
"""Class for Projects""" |
|
|
|
|
|
security=ClassSecurityInfo() |
meta_type='MPIWGProject' |
meta_type='MPIWGProject' |
|
default_catalog='ProjectCatalog' |
|
|
|
|
|
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)) |
|
|
|
founds=self.ZopeFind(self,obj_metatypes=[metatype]); |
|
|
|
founds.sort(sort) |
|
|
|
return founds |
|
|
|
|
|
def copyPublicationsToList(self,RESPONSE=None): |
|
"""copy publications in to list""" |
|
|
|
publicationTxt=self.getContent('WEB_related_pub') |
|
|
|
pubSplits=publicationTxt.split("<p>") |
|
|
|
for pubSplit in pubSplits: |
|
pubSplit=pubSplit.replace("</p>","") |
|
self.addPublication(pubSplit) |
|
|
|
if RESPONSE: |
|
RESPONSE.redirect('managePublications') |
|
|
|
|
|
def copyImageToMargin(self,RESPONSE=None): |
|
"""copy inline images to marginal images""" |
|
|
|
|
|
#getImages from WEB_project_description |
|
description=self.getContent('WEB_project_description') |
|
|
|
text2=description |
|
splitted=text2.split("""<p class="picture">""") |
|
|
|
imageURLs=[] |
|
imageCaptions=[] |
|
for split in splitted[1:]: |
|
tmp=split.split("</p>") |
|
#return repr(splitted[1]) |
|
|
|
try: |
|
imageURLs.append(tmp[0].split("\"")[1].encode('utf-8')) |
|
except: |
|
|
|
try: |
|
imageURLs.append(tmp[0].split("src=")[1].split(" ")[0].encode('utf-8')) |
|
except: |
|
imageURLs.append("") |
|
|
|
split2="</p>".join(tmp[1:]) |
|
|
|
|
|
splitted=split2.split("""<p class="picturetitle">""") |
|
if len(splitted)>1: |
|
tmp=splitted[1].split("</p>") |
|
imageCaptions.append(tmp[0].encode('utf-8')) |
|
|
|
|
|
else: |
|
#keine caption |
|
|
|
imageCaptions.append("") |
|
|
|
|
|
#eintragen: |
|
for imageURL in imageURLs: |
|
filename=imageURL.split("/")[-1] |
|
#lege neues images object an, mit leerem bild |
|
|
|
if self.ZopeFind(self,obj_ids=[filename]): |
|
#existiert das bild schon, dann neuen filenamen |
|
filename="project_image_"+filename |
|
|
|
self.addImage(None,imageCaptions[imageURLs.index(imageURL)],filename=filename) |
|
#hole die bilddaten aus der url |
|
url=self.absolute_url()+"/"+imageURL |
|
#url=self.absolute_url()+"/"+filename |
|
|
|
try:#relative url |
|
data=urllib.urlopen(url).read() |
|
except: |
|
try:#absolute |
|
data=urllib.urlopen(self.imageURL).read() |
|
except: |
|
logger("MPIWG Project",logging.ERROR,"can't open: %s"%url) |
|
|
|
obj=getattr(self,filename) |
|
obj.update_data(data) |
|
|
|
if RESPONSE: |
|
RESPONSE.redirect('manageImages') |
|
|
|
def manageImages(self,imageName=None,op=None): |
|
"""managage images""" |
|
|
|
|
|
if imageName and op: |
|
if op=='up': |
|
images=self.getImages() |
|
for image in images: |
|
if image[0]==imageName: |
|
nr=images.index(image) |
|
if not nr==0: |
|
images[nr-1][1].place+=1 |
|
images[nr][1].place-=1 |
|
pass |
|
elif op=='down': |
|
images=self.getImages() |
|
for image in images: |
|
if image[0]==imageName: |
|
nr=images.index(image) |
|
if not (nr==len(images)-1): |
|
images[nr+1][1].place-=1 |
|
images[nr][1].place+=1 |
|
pass |
|
|
|
|
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','MPIWGProject_manageImagesForm.zpt')).__of__(self) |
|
return pt() |
|
|
|
def managePublications(self,pubName=None,op=None): |
|
"""managage images""" |
|
|
|
|
|
if pubName and op: |
|
if op=='up': |
|
publications=self.getPublications() |
|
for publication in publications: |
|
if publication[0]==pubName: |
|
nr=publications.index(publication) |
|
if not nr==0: |
|
publications[nr-1][1].place+=1 |
|
publications[nr][1].place-=1 |
|
pass |
|
elif op=='down': |
|
publications=self.getPublications() |
|
for publication in publications: |
|
if publication[0]==pubName: |
|
nr=publications.index(publication) |
|
if not (nr==len(publications)-1): |
|
publications[nr+1][1].place-=1 |
|
publications[nr][1].place+=1 |
|
pass |
|
|
|
|
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','MPIWGProject_managePublicationsForm.zpt')).__of__(self) |
|
return pt() |
|
|
|
def getPublications(self): |
|
"""get all Publications""" |
|
def sort_images(x,y): |
|
return cmp(getattr(x[1],'place',0),getattr(y[1],'place',0)) |
|
|
|
publications=self.ZopeFind(self,obj_metatypes=['MPIWGProject_publication']) |
|
|
|
publications.sort(sort_images) |
|
return publications |
|
|
|
def addPublication(self,text,RESPONSE=None): |
|
"""add an MPIWG_Publication""" |
|
|
|
name="publication_"+str(self.getLastPublicationNumber()+1) |
|
|
|
newPublication=MPIWGProject_publication(name) |
|
|
|
self._setObject(name,newPublication) |
|
obj=getattr(self,name) |
|
obj.text=text[0:] |
|
obj.enabled=True; |
|
obj.place=self.getLastPublicationNumber()+1 |
|
obj.id=name |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('managePublications') |
|
|
|
|
|
def getLastPublicationNumber(self): |
|
publications=self.getPublications() |
|
|
|
if not publications: |
|
return 0 |
|
else: |
|
return getattr(publications[-1][1],'place',0) |
|
|
|
def deletePublication(self,id,RESPONSE=None): |
|
"""delete Publication id""" |
|
self.manage_delObjects([id]) |
|
if RESPONSE: |
|
RESPONSE.redirect('managePublications') |
|
|
|
def getImages(self): |
|
"""get all Images""" |
|
|
|
def sort_images(x,y): |
|
return cmp(getattr(x[1],'place',0),getattr(y[1],'place',0)) |
|
|
|
|
|
if (getattr(self,'imageURL','')!='') or (getattr(self,'imagecap','')!='') : |
|
try: |
|
self.addImage(None,getattr(self,'imagecap',''),RESPONSE=None,filename=getattr(self,'imageURL','')) |
|
except: |
|
pass |
|
self.imageURL='' |
|
self.imagecap='' |
|
|
|
images=self.ZopeFind(self,obj_metatypes=['MPIWGProject_image']) |
|
|
|
images.sort(sort_images) |
|
return images |
|
|
|
def getLastImageNumber(self): |
|
images=self.getImages() |
|
|
|
if not images: |
|
return 0 |
|
else: |
|
return getattr(images[-1][1],'place',0) |
|
|
|
def deleteImage(self,id,RESPONSE=None): |
|
"""delete Image id""" |
|
self.manage_delObjects([id]) |
|
if RESPONSE: |
|
RESPONSE.redirect('manageImages') |
|
|
|
|
|
def hasChildren(self,date=None,onlyActive=True): |
|
"""check if project has children""" |
|
ct=self.getContexts(childs=self.getContent('xdata_05'), |
|
depth=1,date=date,onlyActive=onlyActive) |
|
|
|
if ct and len(ct)>0: |
|
return True |
|
else: |
|
return False |
|
|
|
|
|
def addImage(self,fileHd,caption,RESPONSE=None,filename=None): |
|
"""add an MPIWG_Project_image""" |
|
|
|
if not filename: |
|
filename=fileHd.filename |
|
|
|
if not fileHd: |
|
fileHd=file(os.path.join(package_home(globals()),'blank.gif')) |
|
|
|
newImage=MPIWGProject_image(filename,filename,fileHd) |
|
|
|
self._setObject(filename,newImage) |
|
obj=getattr(self,filename) |
|
obj.caption=caption[0:] |
|
obj.enabled=True; |
|
obj.place=self.getLastImageNumber()+1 |
|
obj.id=filename |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manageImages') |
|
|
|
def PrincipiaSearchSource(self): |
|
"""Return cataloguable key for ourselves.""" |
|
return str(self) |
|
|
|
def versionHeader(self): |
|
"""version Header, gibt header text entsprechend der aktuellen version aus""" |
|
|
|
actualTime=time.localtime() |
|
retTXT="""<h2>This is an outdated version, for the actual version please refer to <a href="%s">%s</a></h2>""" |
|
s=self.aq_parent.absolute_url() |
|
#print getattr(self,'archiveTime',actualTime) |
|
if getattr(self,'archiveTime',actualTime)< actualTime: |
|
return retTXT%(s,s) |
|
else: |
|
return "" |
|
|
|
def getActualVersion(self,date=None): |
|
"""actuelle version""" |
|
def sortProjectsByTime(x,y): |
|
return cmp(x[1].archiveTime,y[1].archiveTime) |
|
|
|
if not date: |
|
if self.isActual(): |
|
return self |
|
else: |
|
return None |
|
|
|
#suche ob aeltere versionen vorhanden sind |
|
|
|
finds=self.ZopeFind(self,obj_metatypes=['MPIWGProject']) |
|
if not finds: #wenn nicht dann teste ob die aktuelle version schon existiert hat. |
|
ad=getattr(self,'creationTime','20050101000000') |
|
if int(date)>int(ad): |
|
return self |
|
else: |
|
return None |
|
|
|
|
|
else: |
|
finds.sort(sortProjectsByTime) |
|
|
|
for find in finds: |
|
#gehe durch die alten Projekte und finde das entprechende |
|
if (int(find[1].archiveTime) > int(date)) and (int(date)>int(getattr(find[1],'creationTime','20050101000000'))): |
|
return find[1] |
|
|
|
#kein passendes gefunden, dann teste ob das aktuelle in frage kommt |
|
ad=getattr(self,'creationTime','20050101000000') |
|
|
|
if int(date)>int(ad): |
|
|
|
return self |
|
else: |
|
return None |
|
|
|
|
|
def isActual(self): |
|
"""gibt 1 zurueck wenn aktuell, 0 sonst""" |
|
actualTime=time.localtime() |
|
|
|
|
|
#print getattr(self,'archiveTime',actualTime) |
|
if getattr(self,'archiveTime',actualTime)< actualTime: |
|
return 0 |
|
else: |
|
return 1 |
|
|
|
def copyObjectToArchive(self): |
|
"""kopiere aktuelles objekt ins archiv""" |
|
cb=self.aq_parent.manage_copyObjects(self.getId()) |
|
self.manage_pasteObjects(cb) |
|
actualTime=time.localtime() |
|
|
|
self.manage_renameObject(self.getId(),self.getId()+"_"+time.strftime("%Y%m%d%H%M%S",actualTime)) |
|
obj=getattr(self,self.getId()+"_"+time.strftime("%Y%m%d%H%M%S",actualTime)) |
|
obj.setArchiveTime(time.strftime("%Y%m%d%H%M%S",actualTime)) |
|
ids=[x[0] for x in self.ZopeFind(obj,obj_metatypes=['MPIWGProject'])] |
|
obj.manage_delObjects(ids) |
|
|
|
def setArchiveTime(self,time): |
|
"""set Archive Time""" |
|
self.archiveTime=time[0:] |
|
|
|
def versionManageForm(self): |
|
"""version Manage form:currently only set to invisible""" |
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','MPIWGProject_versionManageForm.zpt')).__of__(self) |
|
return pt() |
|
|
|
def versionManage(self,invisible=None,RESPONSE=None): |
|
"""version Manage form:currently only set to invisible""" |
|
self.invisible=invisible |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
def crossLinker(self): |
def crossLinker(self): |
"""experimental crosslinker""" |
"""experimental crosslinker""" |
Line 747 class MPIWGProject(Folder):
|
Line 1947 class MPIWGProject(Folder):
|
|
|
|
|
def generateTemplate(self,RESPONSE=None): |
def generateTemplate(self,RESPONSE=None): |
"""Erzeuge Template für defined fields not_used""" |
"""Erzeuge Template fuer defined fields not_used""" |
|
|
id="index_html" |
id="index_html" |
title=id |
title=id |
Line 762 class MPIWGProject(Folder):
|
Line 1962 class MPIWGProject(Folder):
|
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
def __init__(self, id, argv=None): |
def __init__(self, id, argv=None): |
"""initieriere classe""" |
"""initiere classe""" |
|
|
|
self.creationTime=time.strftime("%Y%m%d%H%M%S",time.localtime())[0:] |
self.id=id |
self.id=id |
self.title=id |
self.title=id |
|
self.isActiveFlag=True #Flag is true is the project is still active, False if accomplished |
|
|
if argv: |
if argv: |
for arg in definedFields: |
for arg in definedFields: |
try: |
try: |
Line 782 class MPIWGProject(Folder):
|
Line 1985 class MPIWGProject(Folder):
|
{'label':'Edit BasisInfo','action':'editMPIWGBasisForm'}, |
{'label':'Edit BasisInfo','action':'editMPIWGBasisForm'}, |
{'label':'Edit Publications','action':'editMPIWGRelatedPublicationsForm'}, |
{'label':'Edit Publications','action':'editMPIWGRelatedPublicationsForm'}, |
{'label':'Edit Themes & Disciplines','action':'editMPIWGDisciplinesThemesForm'}, |
{'label':'Edit Themes & Disciplines','action':'editMPIWGDisciplinesThemesForm'}, |
|
{'label':'Versionmanager','action':'versionManageForm'}, |
) |
) |
|
|
|
|
|
def isActiveProject(self): |
|
"""check if the project is still active, default is true, set to false is the project is accomplished""" |
|
return getattr(self,'isActiveFlag',True) |
|
|
|
def setActiveFlag(self,status=True): |
|
"""set the active flag""" |
|
self.isActiveFlag=status |
|
|
|
def checkDate(self,date): |
|
"""teste ob zum Zeitpunkt date eine andere version existierte""" |
|
|
|
|
|
def sortProjectsByTime(x,y): |
|
return cmp(x[1].archiveTime,y[1].archiveTime) |
|
|
|
#suche ob aeltere versionen vorhanden sind |
|
|
|
finds=self.ZopeFind(self,obj_metatypes=['MPIWGProject']) |
|
if not finds: #wenn nicht dann teste ob die aktuelle version schon existiert hat. |
|
ad=getattr(self,'creationTime','20050101000000') |
|
if int(date)>int(ad): |
|
return self.REQUEST['URL1']+"/"+self.getId() |
|
else: |
|
return self.REQUEST['URL1']+"/no_project" |
|
|
|
|
|
else: |
|
finds.sort(sortProjectsByTime) |
|
|
|
for find in finds: |
|
#gehe durch die alten Projekte und finde das entprechende |
|
if (int(find[1].archiveTime) > int(date)) and (int(date)>int(getattr(find[1],'creationTime','20050101000000'))): |
|
return self.REQUEST['URL1']+"/"+find[1].getId() |
|
|
|
#kein passendes gefunden, dann teste ob das aktuelle in frage kommt |
|
ad=getattr(self,'creationTime','20050101000000') |
|
|
|
if int(date)>int(ad): |
|
|
|
return self.REQUEST['URL1']+"/"+self.getId() |
|
else: |
|
return self.REQUEST['URL1']+"/no_project" |
|
|
|
|
|
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 getGetNeighbourhood(self,wordStr, length=100,tagging=True): |
|
"""finde umgebung um die worte in wordStr, zurueckgegeben wird eine Array mit den Umgebungen von Fundstellen der Worte |
|
alle Tags werden entfernt, die Fundstellen werden mit <span class="found">XX</span> getaggt, die Umgebungen werden |
|
case insensitive gesucht |
|
@param wordStr: string mit Worten getrennt durch Leerzeichen, Phrasen sind mit " gekennzeichnet |
|
"eine phrase", "*" bezeichnet wildcards und wird ignoriert" |
|
@param length: optional, default wert 100, 2*length ist die groesse der Umgebung |
|
@param tagging: optional default wert true, kein span tag wird erzweugt falls tag=false |
|
""" |
|
|
|
ret=[] # nimmt das Array auf, dass spaeter zurueckgegeben wird |
|
ranges=[] #Array mit tupeln x,y wobei x die Position des Anfang und y des Endes der i-ten Umgebung angiebt |
|
|
|
def isInRanges(nr,length): |
|
"""test ob eine gegeben Position nr schon irgendwo in einer Umgebung ist, gibt den Index des ersten Wertes aus ranges zurueck, |
|
-1, wenn kein Treffer |
|
|
|
@param nr: Position die geprueft werden soll |
|
@param length: Laenge des Wortes das geprueft werden soll |
|
""" |
|
for x in ranges: |
|
if (x[0]<=nr) and (nr < (x[1]-length)): |
|
return ranges.index(x) |
|
return -1 |
|
|
|
# deal with phrases, in Phrasen werden die Leerzeichen durch "_" ersetzt. |
|
def rep_empty(str): |
|
x= re.sub(" ","_",str.group(0)) |
|
return re.sub("\"","",x) |
|
|
|
wordStr=re.sub("\".*?\"", rep_empty,wordStr)#ersetze leerzeichen in " " durch "_" und loesche " |
|
|
|
#deal with wildcards, for our purposes it is enough to delete the wildcard |
|
wordStr=wordStr.replace("*","") |
|
|
|
words=wordStr.split(" ") |
|
#if not words is ListType: |
|
# words=[words] |
|
|
|
txt=self.harvest_page() |
|
if not txt: |
|
return ret |
|
txt=re.sub("<.*?>", "", txt) # loesche alle Tags |
|
for word in words: |
|
word=re.sub("_"," ",word) # ersetze zurueck "_" durch " " |
|
pos=0 |
|
|
|
n=txt.lower().count(word.lower()) # wie oft tritt das Wort auf |
|
|
|
for i in range(n): |
|
pos=txt.lower().find(word.lower(),pos) |
|
|
|
if pos > 0: |
|
x=max(0,pos-length) |
|
y=min(len(txt),pos+length) |
|
|
|
|
|
#is word already in one of the results |
|
nr=isInRanges(pos,len(word)) |
|
if nr >=0:# word ist in einer schon gefunden Umgebung, dann vergroessere diese |
|
x=min(ranges[nr][0],x) |
|
y=max(ranges[nr][1],y) |
|
|
|
str=txt[x:y] |
|
|
|
if nr >=0: # word ist in einer schon gefunden Umgebung |
|
ranges[nr]=(x,y) # neue Position der Umgebung |
|
|
|
ret[nr]=str # neue Umgebung |
|
else: # andernfalls neue Umgebung hinzufuegen |
|
ranges.append((x,y)) |
|
|
|
ret.append(str) |
|
|
|
pos=pos+len(word) |
|
else: |
|
break; |
|
|
|
# now highlight everything |
|
if tagging: |
|
for x in range(len(ret)): |
|
for word in words: |
|
repl=re.compile(word,re.IGNORECASE) |
|
ret[x]=repl.sub(""" <span class="found">%s</span>"""%word.upper(),ret[x]) |
|
|
|
return ret |
|
|
|
def harvest_page(self,context=None): |
|
"""seite fuer harvesting fuer die Projektsuche""" |
|
if not context: |
|
context=self |
|
|
|
if self.isActiveProject() and self.isActual(): |
|
ext=getattr(self,"harvest_main",None) |
|
if ext: |
|
return getattr(self,ext.getId())() |
|
|
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','harvest_main')).__of__(context) |
|
|
|
|
|
return pt() |
|
|
|
def index_html(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 getDataFields(self): |
def getDataFields(self): |
"""giveListofDatafields""" |
"""giveListofDatafields""" |
ret=[] |
ret=[] |
Line 801 class MPIWGProject(Folder):
|
Line 2178 class MPIWGProject(Folder):
|
"""get attrbiute""" |
"""get attrbiute""" |
return getattr(self,field) |
return getattr(self,field) |
|
|
def getContent(self,field): |
def getContent(self,field,filter=None): |
"""Inhalt des Feldes""" |
"""Inhalt des Feldes""" |
|
|
text=u'' |
text=u'' |
#print "FIELD",field |
|
for x in getattr(self,field): |
for x in getattr(self,field): |
#print "HIHIIII" |
|
|
|
try: |
try: |
text +=x.encode('utf-8') |
text +=x |
except: |
|
try: |
|
text =x.encode('utf-8') |
|
except: |
except: |
text=x.decode('latin-1').encode('utf-8') |
text = x |
|
|
|
|
|
|
#delete separator (;) if is there is one |
|
## try: |
|
## print text, text[len(text)-1] |
|
## except: |
|
## print "error:",text |
|
try: |
try: |
if text[len(text)-1]==";": |
if text[len(text)-1]==";": |
text=text[0:len(text)-1] |
text=text[0:len(text)-1] |
|
|
|
|
except: |
except: |
"""nothing""" |
pass |
|
|
|
if text=='': |
|
text2=text |
|
else: |
text2=re.sub(r';([^\s])','; \g<1>',text) |
text2=re.sub(r';([^\s])','; \g<1>',text) |
|
|
#teste ob ergebnis leer und header dann nehme title |
#teste ob ergebnis leer und header dann nehme title |
|
|
if (text2=='') and (field=='WEB_project_header'): |
if (text2=='') and (field=='WEB_project_header'): |
return self.getContent('WEB_title') |
return self.getContent('WEB_title') |
|
|
#teste ob WEB_project_description und keine führenden p tags |
if filter: |
if (len(text2)>4) and (not text2[0:3]=='<p>') and (field=='WEB_project_description'): |
splitted=text2.split("""<p class="picture">""") |
return "<p>"+text2+"</p>" |
if len(splitted)>1: |
|
tmp=splitted[1].split("</p>") |
|
#return repr(splitted[1]) |
|
try: |
|
self.imageURL=tmp[0].split("\"")[1].encode('utf-8') |
|
except: |
|
try: |
|
self.imageURL=tmp[0].split("src=")[1].split(" ")[0].encode('utf-8') |
|
except: |
|
self.imageURL="" |
|
|
|
split2="</p>".join(tmp[1:]) |
|
|
|
text3=splitted[0]+split2 |
|
|
|
splitted=text3.split("""<p class="picturetitle">""") |
|
if len(splitted)>1: |
|
tmp=splitted[1].split("</p>") |
|
self.imagecap=tmp[0].encode('utf-8') |
|
|
|
split4="".join(tmp[1:]) |
|
|
|
text5=splitted[0]+split4 |
|
else: |
|
#keine caption |
|
text5=text3 |
|
else: |
|
#kein bild |
|
text5=text2 |
|
else: |
|
text5=text2 |
|
|
|
#teste ob WEB_project_description und keine fuehrenden p tags |
|
if (len(text5)>4) and (not text5[0:3]=='<p>') and (field=='WEB_project_description'): |
|
text5= "<p>"+text5+"</p>" |
|
|
|
|
|
#filter image |
|
|
|
text5=text5.lstrip().rstrip() #loescher leerzeichen und einzelndes br |
|
if (text5=="<br>") or (text5=="<br/>"): |
|
text5="" |
|
|
|
return text5.encode('utf-8') |
|
|
|
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() |
|
|
return text2 |
|
|
|
def show_html(self): |
def show_html(self): |
"""simple index""" |
"""simple index""" |
#return "HI" |
#return "HI" |
pt=PageTemplateFile('Products/MPIWGWeb/zpt/MPIWGProject_index.zpt').__of__(self) |
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','MPIWGProject_index.zpt')).__of__(self) |
return pt() |
return pt() |
|
|
|
def saveFromPreview(self): |
|
"""save content aus preview""" |
|
self.WEB_project_description=self.previewTemplate.WEB_project_description[0:] |
|
self.REQUEST.RESPONSE.redirect("./index.html") |
|
|
|
def saveEditedContent(self,kupu=None,preview=None): |
|
"""save Edited content""" |
|
|
|
if preview: |
|
kupu=preview |
|
#find content of body tags |
|
start=kupu.find("<body>") |
|
end=kupu.find("</body>") |
|
newcontent= kupu[start+6:end] |
|
|
|
if preview: |
|
|
|
return self.preview(newcontent) |
|
|
|
self.copyObjectToArchive() |
|
self.WEB_project_description=newcontent[0:] |
|
|
|
self.REQUEST.RESPONSE.redirect("./index.html") |
|
|
|
return True |
|
|
|
security.declareProtected('View management screens','edit') |
|
def edit(self,western=None): |
|
"""Edit pages""" |
|
if western: |
|
self.REQUEST.RESPONSE.setCookie("MP_debug_code","western",path="/") |
|
|
|
|
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','edit_MPIWGProjectNeu.zpt')).__of__(self) |
|
return pt() |
|
|
|
edit_MPIWGProject_main = PageTemplateFile('zpt/edit_MPIWGProject_main', globals()) |
|
|
|
def getPathStyle(self, path, selected, style=""): |
|
"""returns a string with the given style + 'sel' if path == selected.""" |
|
|
|
if path == selected: |
|
return style + 'sel' |
|
else: |
|
return style |
|
|
|
def preview(self,description): |
|
"""preview""" |
|
tmpPro=getattr(self,"previewTemplate",None) |
|
if not tmpPro: |
|
tmpPro=MPIWGProject("previewTemplate") |
|
self._setObject("previewTemplate",tmpPro) |
|
for field in definedFields: |
|
setattr(tmpPro,field,getattr(self,field)) |
|
tmpPro.WEB_project_description=description[0:] |
|
tmpPro.invisible=True |
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','previewFrame.zpt')).__of__(self) |
|
return pt() |
|
|
|
#return self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']+"/previewTemplate") |
|
|
|
|
|
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 |
|
</html></body> |
|
"""%self.WEB_project_description[0] |
|
|
|
return """ |
|
<html> |
|
<head> |
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
|
</head> |
|
<body>%s |
|
</html></body> |
|
"""%self.getContent('WEB_project_description') |
|
|
|
|
|
|
def editMPIWGProjectForm(self): |
def editMPIWGProjectForm(self): |
"""editform""" |
"""editform""" |
pt=PageTemplateFile('Products/MPIWGWeb/zpt/edit_MPIWGProject.zpt').__of__(self) |
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','edit_MPIWGProject.zpt')).__of__(self) |
return pt() |
return pt() |
|
|
def editMPIWGProject(self,RESPONSE=None): |
|
"""edit the project""" |
|
|
|
#return self.REQUEST |
def editMPIWGProject(self,RESPONSE=None,fromEdit=None): |
|
"""edit the project and archive the old version""" |
|
|
|
self.copyObjectToArchive() # archive the object |
|
|
|
|
for x in definedFields: |
for x in definedFields: |
if self.REQUEST.has_key(x): |
if self.REQUEST.has_key(x): |
|
|
setattr(self,x,[self.REQUEST[x].decode('utf-8')]) |
setattr(self,x,[self.REQUEST[x].decode('utf-8')]) |
|
|
|
|
|
if self.REQUEST.has_key('historicalNames'): |
|
self.en.changeHistoricalNames(self.getId(),self.REQUEST['historicalNames'].split("\n")) |
|
|
|
if self.REQUEST.has_key('active'): |
|
self.setActiveFlag(True) |
|
else: |
|
self.setActiveFlag(False) |
|
if fromEdit and (RESPONSE is not None): |
|
RESPONSE.redirect('./editMPIWGBasisEditor') |
|
|
|
else: |
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
|
|
|
|
|
security.declareProtected('View managment screens','editMPIWGDisciplinesThemesEditor') |
|
def editMPIWGDisciplinesThemesEditor(self): |
|
"""edit from edit""" |
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','edit_MPIWGDisciplinesThemesNeu.zpt')).__of__(self) |
|
return pt() |
|
|
|
|
def editMPIWGDisciplinesThemesForm(self): |
def editMPIWGDisciplinesThemesForm(self): |
"""edit the disciplines and themes Form""" |
"""edit the disciplines and themes Form""" |
pt=PageTemplateFile('Products/MPIWGWeb/zpt/edit_MPIWGDisciplinesThemes.zpt').__of__(self) |
|
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','edit_MPIWGDisciplinesThemes.zpt')).__of__(self) |
return pt() |
return pt() |
|
|
def editMPIWGDisciplinesThemes(self,disciplines=None,themes=None,RESPONSE=None): |
def editMPIWGDisciplinesThemes(self,disciplines=None,themes=None,RESPONSE=None,fromEdit=None): |
"""edit disciplin and form""" |
"""edit disciplin and form""" |
if disciplines: |
if disciplines: |
if type(disciplines) is StringType: |
if type(disciplines) is StringType: |
Line 887 class MPIWGProject(Folder):
|
Line 2421 class MPIWGProject(Folder):
|
else: |
else: |
self.xdata_10="" |
self.xdata_10="" |
|
|
|
if fromEdit and (RESPONSE is not None): |
|
RESPONSE.redirect('./editMPIWGDisciplinesThemesEditor') |
|
|
|
else: |
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
|
|
def isChecked(self,wert,list): |
def isChecked(self,wert,list): |
"""check if wert is in ; seperated list""" |
"""check if wert is in ; seperated list""" |
print "W:",wert |
|
print "L:",list,type(list) |
|
#felder sind manchmnal als liste mit einem element definiert |
#felder sind manchmnal als liste mit einem element definiert |
if type(list) is StringType or UnicodeType: |
if type(list) is StringType or UnicodeType: |
splitted=list.split(";") |
splitted=list.split(";") |
else: |
else: |
splitted=list[0].split(";") |
splitted=list[0].split(";") |
|
|
print splitted |
splitted=[y.rstrip().lstrip() for y in splitted] |
|
|
for x in splitted: |
for x in splitted: |
|
x=re.sub(r"[^A-z ]","",x) |
if (not x==u'') and x in wert: |
if (not x==u'') and x in wert: |
return 1 |
return 1 |
return 0 |
return 0 |
|
|
|
security.declareProtected('View management screens','editMPIWGBasisEditor') |
|
def editMPIWGBasisEditor(self): |
|
"""editform""" |
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','edit_MPIWGBasisNeu.zpt')).__of__(self) |
|
return pt() |
|
|
|
security.declareProtected('View management screens','editMPIWGBasisForm') |
def editMPIWGBasisForm(self): |
def editMPIWGBasisForm(self): |
"""editform""" |
"""editform""" |
pt=PageTemplateFile('Products/MPIWGWeb/zpt/edit_MPIWGBasis.zpt').__of__(self) |
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','edit_MPIWGBasis.zpt')).__of__(self) |
return pt() |
return pt() |
|
|
|
security.declareProtected('View management screens','editMPIWGRelatedPublicationsForm') |
def editMPIWGRelatedPublicationsForm(self): |
def editMPIWGRelatedPublicationsForm(self): |
"""Edit related Publications""" |
"""Edit related Publications""" |
pt=PageTemplateFile('Products/MPIWGWeb/zpt/edit_MPIWGRelatedPublications.zpt').__of__(self) |
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','edit_MPIWGRelatedPublications.zpt')).__of__(self) |
return pt() |
return pt() |
|
|
|
|
def loadNewFileForm(self): |
def loadNewFileForm(self): |
"""Neues XML-File einlesen""" |
"""Neues XML-File einlesen""" |
pt=PageTemplateFile('Products/MPIWGWeb/zpt/MPIWGProject_newfile.zpt').__of__(self) |
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','MPIWGProject_newfile.zpt')).__of__(self) |
return pt() |
return pt() |
|
|
def loadNewFile(self,RESPONSE=None): |
def loadNewFile(self,RESPONSE=None): |
Line 947 class MPIWGProject(Folder):
|
Line 2495 class MPIWGProject(Folder):
|
|
|
def manage_addMPIWGProjectForm(self): |
def manage_addMPIWGProjectForm(self): |
"""form for adding the project""" |
"""form for adding the project""" |
pt=PageTemplateFile('Products/MPIWGWeb/zpt/addMPIWGProjectForm.zpt').__of__(self) |
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addMPIWGProjectForm.zpt')).__of__(self) |
return pt() |
return pt() |
|
|
def manage_addMPIWGProject(self,id,RESPONSE=None): |
def manage_addMPIWGProject(self,id,RESPONSE=None): |
Line 955 def manage_addMPIWGProject(self,id,RESPO
|
Line 2503 def manage_addMPIWGProject(self,id,RESPO
|
#print argv |
#print argv |
fileupload=self.REQUEST.get('fileupload',None) |
fileupload=self.REQUEST.get('fileupload',None) |
if fileupload: |
if fileupload: |
print fileupload |
|
file_name=fileupload.filename |
file_name=fileupload.filename |
filedata=fileupload.read() |
filedata=fileupload.read() |
|
|