version 1.8, 2004/05/28 16:45:06
|
version 1.9, 2004/06/28 18:47:14
|
Line 1
|
Line 1
|
"""This files contains the class MPIWG Projects |
"""This contains the class MPIWG Projects |
for organizing and maintaining the different projectspages |
for organizing and maintaining the different projectspages |
|
|
""" |
""" |
Line 19 definedFields=['WEB_title','xdata_01','x
|
Line 19 definedFields=['WEB_title','xdata_01','x
|
|
|
checkFields = ['xdata_01'] |
checkFields = ['xdata_01'] |
|
|
def sortF(x,y): |
|
|
|
|
|
|
def sortF(x,y): |
|
try: |
return cmp(x[1],y[1]) |
return cmp(x[1],y[1]) |
|
except: |
|
return 0 |
|
|
def sortI(x,y): |
def sortI(x,y): |
xsplit=x[1].split(".") |
xsplit=x[1].split(".") |
Line 49 def sortI(x,y):
|
Line 53 def sortI(x,y):
|
class MPIWGRoot(Folder): |
class MPIWGRoot(Folder): |
"""Stammordner für den Web-Server""" |
"""Stammordner für den Web-Server""" |
|
|
|
fieldLabels={'WEB_title':'WEB_Title','xdata_01':'Responsible Scientists','xdata_02':'Department', |
|
'xdata_03':'Historical Persons','xdata_04':'Time period', |
|
'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_11':'Object Digitallibrary','xdata_12':'Cooperation partners', |
|
'xdata_13':'Funding institutions','WEB_project_header':'WEB_project_header', |
|
'WEB_project_description':'WEB_project_description','WEB_related_pub':'WEB_related_pub'} |
|
|
folders=['MPIWGProject','Folder'] |
folders=['MPIWGProject','Folder'] |
meta_type='MPIWGRoot' |
meta_type='MPIWGRoot' |
|
|
|
def getValue(self,field): |
|
"""Inhalt des Feldes""" |
|
|
|
if type(field)==StringType: |
|
try: |
|
if field[len(field)-1]==";": |
|
field=field[0:len(text)-1] |
|
except: |
|
"""nothing""" |
|
|
|
return field.encode('utf-8') |
|
|
|
else: |
|
return field[0].encode('utf-8') |
|
|
|
|
def sortedNames(self,list): |
def sortedNames(self,list): |
"""sort names""" |
"""sort names""" |
|
|
Line 179 class MPIWGRoot(Folder):
|
Line 207 class MPIWGRoot(Folder):
|
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): |
def test(self): |
"""test""" |
"""test""" |
return self.getProjectsByFieldContent('xdata_09',['biology'])[0].absolute_url |
return self.getProjectsByFieldContent('xdata_09',['biology'])[0].absolute_url |
|
|
|
def getContexts(self,childs=None,parents=None,depth=None): |
|
"""childs alle childs, alle parents""" |
|
ret=[] |
|
if parents: |
|
splitted=parents.split(".") |
|
parentId=string.join(splitted[0:len(splitted)-1],".") |
|
|
|
for project in self.getProjectFields('xdata_05',sort='int'): |
|
if project[1]==parentId: |
|
ret.append(project) |
|
|
|
if childs: |
|
for project in self.getProjectFields('xdata_05',sort='int'): |
|
searchStr=childs+"(\..*)" |
|
if re.match(searchStr,project[1]): |
|
|
|
if depth: |
|
print "ho" |
|
if int(depth)>=len(project[1].split("."))-len(childs.split(".")): |
|
|
|
ret.append(project) |
|
else: |
|
ret.append(project) |
|
return ret |
|
|
def getProjectFields(self,fieldName,folder=None,sort=None): |
def getProjectFields(self,fieldName,folder=None,sort=None): |
"""getListofFieldNames""" |
"""getListofFieldNames""" |
ret=[] |
ret=[] |
Line 232 class MPIWGRoot(Folder):
|
Line 292 class MPIWGRoot(Folder):
|
manage_options = Folder.manage_options+( |
manage_options = Folder.manage_options+( |
{'label':'Import Persons','action':'importNamesForm'}, |
{'label':'Import Persons','action':'importNamesForm'}, |
{'label':'Main config','action':'changeMPIWGRootForm'}, |
{'label':'Main config','action':'changeMPIWGRootForm'}, |
|
{'label':'Edit Historical Persons','action':'editHistoricalPersonsForm'}, |
{'label':'Store Historical Persons','action':'storeHistoricalPersons'}, |
{'label':'Store Historical Persons','action':'storeHistoricalPersons'}, |
) |
) |
|
|
Line 243 class MPIWGRoot(Folder):
|
Line 304 class MPIWGRoot(Folder):
|
def importNames(self,fileupload,folderName,RESPONSE=None): |
def importNames(self,fileupload,folderName,RESPONSE=None): |
"""import komma-sep list email,lastName,firstName""" |
"""import komma-sep list email,lastName,firstName""" |
project=getattr(self,folderName) |
project=getattr(self,folderName) |
|
load=fileupload.read() |
|
|
|
for line in load.split('\r'): |
|
|
|
|
for line in fileupload.readlines(): |
|
#print line |
|
splitted=line.split(",") |
splitted=line.split(",") |
|
print splitted |
|
|
if not (splitted[0]==""): |
if not (splitted[0]==""): |
newObj=MPIWGStaff.MPIWGStaff(splitted[0],splitted[1],splitted[2]) |
newObj=MPIWGStaff.MPIWGStaff(splitted[0],splitted[1],splitted[2]) |
|
|
try: |
try: |
project._setObject(splitted[0],newObj) |
project._setObject(splitted[0],newObj) |
|
print "done:",splitted[0] |
except: |
except: |
print "not done:",splitted[0] |
print "not done:",splitted[0] |
|
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
Line 260 class MPIWGRoot(Folder):
|
Line 328 class MPIWGRoot(Folder):
|
"""give list of all members""" |
"""give list of all members""" |
ret=[] |
ret=[] |
|
|
for x in self.members.objectValues('MPIWGStaff'): |
#for x in self.members.objectValues('MPIWGStaff'): |
#print x.title |
#print x.title |
ret.append(x.title) |
# ret.append(x.title.decode('utf-8')) |
|
|
|
for x in self.ZopeFind(self.members,obj_metatypes=['MPIWGStaff']): |
|
ret.append(x[1].title.decode('utf-8')) |
|
|
ret.sort() |
#ret.sort() |
|
#print ret |
|
|
|
return ret |
|
|
|
def printAllMembers(self): |
|
"""prin""" |
|
members=self.getAllMembers() |
|
ret="" |
|
for x in members: |
|
ret+="<p>%s</p>"%x |
return ret |
return ret |
|
|
|
|
def makeList(self,entry): |
def makeList(self,entry): |
"""makes a list out of one entry or repeat a list""" |
"""makes a list out of one entry or repeat a list""" |
if type(entry) is StringType: |
if type(entry) is StringType: |
Line 285 class MPIWGRoot(Folder):
|
Line 367 class MPIWGRoot(Folder):
|
depth=len(splittedId) |
depth=len(splittedId) |
nr=idNr |
nr=idNr |
title=project[0].WEB_title |
title=project[0].WEB_title |
|
|
returnList.append((depth,nr,title,project[0])) |
returnList.append((depth,nr,title,project[0])) |
|
|
return returnList |
return returnList |
Line 355 class MPIWGRoot(Folder):
|
Line 438 class MPIWGRoot(Folder):
|
persons=list.split(";") |
persons=list.split(";") |
for person in persons: |
for person in persons: |
|
|
|
if len(person)>1: #nicht nur Trennzeichen |
splitted=person.split(",") |
splitted=person.split(",") |
if len(splitted)==1: |
if len(splitted)==1: |
splitted=person.split(" ") |
splitted=person.split(" ") |
Line 362 class MPIWGRoot(Folder):
|
Line 446 class MPIWGRoot(Folder):
|
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=='': |
|
|
try: |
try: |
Line 379 class MPIWGRoot(Folder):
|
Line 464 class MPIWGRoot(Folder):
|
"""give tuple member /projects""" |
"""give tuple member /projects""" |
ret=[] |
ret=[] |
members=self.getAllMembers() |
members=self.getAllMembers() |
|
#return str(members) |
for x in members: |
for x in members: |
splitted=x.split(",") |
y=x.encode('utf-8') |
|
splitted=y.split(",") |
|
splitNeu=[] |
|
for s in splitted: |
|
|
|
splitNeu.append("\""+s+"\"") |
|
search=string.join(splitNeu,' AND ') |
|
proj=self.ProjectCatalog({'xdata_01':search}) |
|
|
proj=self.ProjectCatalog({'xdata_01':string.join(splitted,' AND')}) |
print "Search:",search,"Found:",proj |
if proj: |
if proj: |
ret.append((x,proj)) |
ret.append((y,proj)) |
|
else: |
|
ret.append((y,None)) |
return ret |
return ret |
def givePersonList(self,name): |
def givePersonList(self,name): |
"""check if person is in personfolder and return list of person objects""" |
"""check if person is in personfolder and return list of person objects""" |
Line 461 class MPIWGRoot(Folder):
|
Line 556 class MPIWGRoot(Folder):
|
|
|
|
|
|
|
|
|
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('Products/MPIWGWeb/zpt/addMPIWGRootForm.zpt').__of__(self) |
Line 535 class MPIWGProject(Folder):
|
Line 631 class MPIWGProject(Folder):
|
{'label':'Edit ProjectInfo','action':'editMPIWGProjectForm'}, |
{'label':'Edit ProjectInfo','action':'editMPIWGProjectForm'}, |
{'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'}, |
) |
) |
|
|
def getDataFields(self): |
def getDataFields(self): |
Line 562 class MPIWGProject(Folder):
|
Line 659 class MPIWGProject(Folder):
|
#print "HIHIIII" |
#print "HIHIIII" |
|
|
try: |
try: |
text +=x |
text +=x.encode('utf-8') |
except: |
except: |
try: |
try: |
text =x |
text =x.encode('utf-8') |
except: |
except: |
text="ERROR" |
text="ERROR" |
#print "TEXT",text.encode('ascii','ignore') |
|
|
#delete separator (;) if is there is one |
|
try: |
|
if text[len(text)-1]==";": |
|
text=text[0:len(text)-1] |
|
except: |
|
"""nothing""" |
|
|
return text |
return text |
|
|
|
|
def show_html(self): |
def show_html(self): |
"""simple index""" |
"""simple index""" |
#return "HI" |
#return "HI" |
Line 582 class MPIWGProject(Folder):
|
Line 687 class MPIWGProject(Folder):
|
pt=PageTemplateFile('Products/MPIWGWeb/zpt/edit_MPIWGProject.zpt').__of__(self) |
pt=PageTemplateFile('Products/MPIWGWeb/zpt/edit_MPIWGProject.zpt').__of__(self) |
return pt() |
return pt() |
|
|
def editMPIWGBasisForm(self): |
|
"""editform""" |
|
pt=PageTemplateFile('Products/MPIWGWeb/zpt/edit_MPIWGBasis.zpt').__of__(self) |
|
return pt() |
|
def editMPIWGRelatedPublicationsForm(self): |
|
"""Edit related Publications""" |
|
pt=PageTemplateFile('Products/MPIWGWeb/zpt/edit_MPIWGRelatedPublications.zpt').__of__(self) |
|
return pt() |
|
|
|
def editMPIWGProject(self,RESPONSE=None): |
def editMPIWGProject(self,RESPONSE=None): |
"""edit the project""" |
"""edit the project""" |
|
|
Line 598 class MPIWGProject(Folder):
|
Line 694 class MPIWGProject(Folder):
|
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]]) |
setattr(self,x,[self.REQUEST[x].decode('utf-8')]) |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
def editMPIWGDisciplinesThemesForm(self): |
|
"""edit the disciplines and themes Form""" |
|
pt=PageTemplateFile('Products/MPIWGWeb/zpt/edit_MPIWGDisciplinesThemes.zpt').__of__(self) |
|
return pt() |
|
|
|
def editMPIWGDisciplinesThemes(self,disciplines=None,themes=None,RESPONSE=None): |
|
"""edit disciplin and form""" |
|
if disciplines: |
|
if type(disciplines) is StringType: |
|
self.xdata_09=disciplines |
|
else: |
|
self.xdata_09=string.join(disciplines,";") |
|
else: |
|
self.xdata_09="" |
|
if themes: |
|
if type(themes) is StringType: |
|
self.xdata_10=themes |
|
else: |
|
self.xdata_10=string.join(themes,";") |
|
else: |
|
self.xdata_10="" |
|
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
|
|
|
def isChecked(self,wert,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 |
|
if type(list) is StringType or UnicodeType: |
|
splitted=list.split(";") |
|
else: |
|
splitted=list[0].split(";") |
|
|
|
print splitted |
|
for x in splitted: |
|
if (not x==u'') and x in wert: |
|
return 1 |
|
return 0 |
|
|
|
def editMPIWGBasisForm(self): |
|
"""editform""" |
|
pt=PageTemplateFile('Products/MPIWGWeb/zpt/edit_MPIWGBasis.zpt').__of__(self) |
|
return pt() |
|
def editMPIWGRelatedPublicationsForm(self): |
|
"""Edit related Publications""" |
|
pt=PageTemplateFile('Products/MPIWGWeb/zpt/edit_MPIWGRelatedPublications.zpt').__of__(self) |
|
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('Products/MPIWGWeb/zpt/MPIWGProject_newfile.zpt').__of__(self) |