version 1.1.2.28, 2010/07/15 10:20:17
|
version 1.1.2.33, 2012/01/06 08:23:10
|
Line 29 import copy
|
Line 29 import copy
|
import updatePersonalWWW |
import updatePersonalWWW |
import MPIWGStaff |
import MPIWGStaff |
from MPIWGHelper import * |
from MPIWGHelper import * |
|
from BeautifulSoup import BeautifulSoup, Comment |
|
|
def sortWeight(x,y): |
def sortWeight(x,y): |
x1=int(getattr(x[1],'weight','0')) |
x1=int(getattr(x[1],'weight','0')) |
Line 67 class MPIWGRoot(ZSQLExtendFolder):
|
Line 67 class MPIWGRoot(ZSQLExtendFolder):
|
# types of objects that show up in navigation |
# types of objects that show up in navigation |
nav_meta_types = ['MPIWGTemplate','MPIWGLink','MPIWGFolder'] |
nav_meta_types = ['MPIWGTemplate','MPIWGLink','MPIWGFolder'] |
|
|
|
manage_options = Folder.manage_options+( |
|
{'label':'Update personal homepages','action':'updatePersonalwww_html'}, |
|
{'label':'Reindex catalogs','action':'reindexCatalogs'}, |
|
{'label':'Main config','action':'changeMPIWGRootForm'}, |
|
{'label':'add e-mails','action':'showNewDBEntries'}, |
|
#{'label':'update the institutsbibliography','action':'updateInstitutsbiliography'}, |
|
#{'label':'Edit Historical Persons','action':'editHistoricalPersonsForm'}, |
|
#{'label':'Store Historical Persons','action':'storeHistoricalPersons'}, |
|
) |
|
|
|
|
def getGetNeighbourhood(self,obj, wordStr, length=100,tagging=True): |
def getGetNeighbourhood(self,obj, wordStr, length=100,tagging=True): |
"""finde umgebung um die worte in wordStr, zurueckgegeben wird eine Array mit den Umgebungen von Fundstellen der Worte |
"""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 |
alle Tags werden entfernt, die Fundstellen werden mit <span class="found">XX</span> getaggt, die Umgebungen werden |
Line 111 class MPIWGRoot(ZSQLExtendFolder):
|
Line 122 class MPIWGRoot(ZSQLExtendFolder):
|
txt=obj.harvest_page() |
txt=obj.harvest_page() |
if not txt: |
if not txt: |
return ret |
return ret |
txt=re.sub("<.*?>", "", txt) # loesche alle Tags |
|
|
soup = BeautifulSoup(txt) |
|
|
|
comments = soup.findAll(text=lambda text:isinstance(text, Comment)) |
|
[comment.extract() for comment in comments] |
|
|
|
txt = ''.join(soup.findAll(text=True)) |
|
|
|
|
|
#txt=re.sub("<.*?>", "", txt) # loesche alle Tags |
for word in words: |
for word in words: |
word=re.sub("_"," ",word) # ersetze zurueck "_" durch " " |
word=re.sub("_"," ",word) # ersetze zurueck "_" durch " " |
pos=0 |
pos=0 |
Line 133 class MPIWGRoot(ZSQLExtendFolder):
|
Line 153 class MPIWGRoot(ZSQLExtendFolder):
|
y=max(ranges[nr][1],y) |
y=max(ranges[nr][1],y) |
|
|
str=txt[x:y] |
str=txt[x:y] |
|
if x!=0: #add dots if in the middle of text |
|
str="..."+str |
|
|
|
if y!=len(txt): #add dots if in the middle of text |
|
str=str+"..." |
|
|
|
|
|
|
if nr >=0: # word ist in einer schon gefunden Umgebung |
if nr >=0: # word ist in einer schon gefunden Umgebung |
ranges[nr]=(x,y) # neue Position der Umgebung |
ranges[nr]=(x,y) # neue Position der Umgebung |
Line 589 class MPIWGRoot(ZSQLExtendFolder):
|
Line 616 class MPIWGRoot(ZSQLExtendFolder):
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'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,connection_id,lang=None,RESPONSE=None): |
def changeMPIWGRoot(self,title,connection_id,coneServiceURL,lang=None,autocommit=None,RESPONSE=None): |
"""change""" |
"""change""" |
self.title=title |
self.title=title |
self.connection_id=connection_id |
self.connection_id=connection_id |
self.disciplineList=disciplineList |
#self.disciplineList=disciplineList |
self.themesList=themesList |
#self.themesList=themesList |
|
self.coneServiceURL=coneServiceURL |
|
|
if lang is not None: |
if lang is not None: |
self.lang = lang |
self.lang = lang |
|
|
|
self.autocommit = (autocommit == "on") |
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
Line 683 class MPIWGRoot(ZSQLExtendFolder):
|
Line 713 class MPIWGRoot(ZSQLExtendFolder):
|
return projects |
return projects |
|
|
|
|
manage_options = Folder.manage_options+( |
|
{'label':'Update personal homepages','action':'updatePersonalwww_html'}, |
|
{'label':'Reindex catalogs','action':'reindexCatalogs'}, |
|
{'label':'Main config','action':'changeMPIWGRootForm'}, |
|
{'label':'add e-mails','action':'showNewDBEntries'}, |
|
{'label':'update the institutsbibliography','action':'updateInstitutsbiliography'}, |
|
#{'label':'Edit Historical Persons','action':'editHistoricalPersonsForm'}, |
|
#{'label':'Store Historical Persons','action':'storeHistoricalPersons'}, |
|
) |
|
|
|
|
|
def updatePublicationDB(self,personId=None): |
def updatePublicationDB(self,personId=None): |
"""updates the publication db, i.e. copy year and type into the main table""" |
"""updates the publication db, i.e. copy year and type into the main table""" |
|
|
Line 791 class MPIWGRoot(ZSQLExtendFolder):
|
Line 810 class MPIWGRoot(ZSQLExtendFolder):
|
if ignoreEntries is None: |
if ignoreEntries is None: |
ignoreEntries = [] |
ignoreEntries = [] |
|
|
ignoreEntries.append('current_work') # TODO:updatecurrent work |
#ignoreEntries.append('current_work') # TODO:updatecurrent work |
logging.debug("updatePersonEntry: data=%s ignoreEntries=%s"%(repr(data),repr(ignoreEntries))) |
logging.debug("updatePersonEntry: data=%s ignoreEntries=%s"%(repr(data),repr(ignoreEntries))) |
|
|
if data['date_to']=="": # wenn date_to leer |
if data['date_to']=="": # wenn date_to leer |
Line 883 class MPIWGRoot(ZSQLExtendFolder):
|
Line 902 class MPIWGRoot(ZSQLExtendFolder):
|
ret+="<table border='1'>" |
ret+="<table border='1'>" |
for iE in displayIgnored: |
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+="<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>" |
ret+="</table>" |
|
|
self.updatePersonEntry(resultSet[conflict],ignoreEntries=ignoreEntries) |
self.updatePersonEntry(resultSet[conflict],ignoreEntries=ignoreEntries) |
|
|
Line 1501 class MPIWGRoot(ZSQLExtendFolder):
|
Line 1520 class MPIWGRoot(ZSQLExtendFolder):
|
return "done" |
return "done" |
|
|
|
|
|
def sortResults(self,results): |
|
"""search the catalog and give results back sorted by meta_type""" |
|
ret = {} |
|
logging.debug(results()) |
|
for result in results(): |
|
metaType = result.meta_type |
|
resultList= ret.get(metaType,[]) |
|
resultList.append(result) |
|
ret[metaType]=resultList |
|
|
|
logging.debug(ret) |
|
return ret |
|
|
|
|
def manage_addMPIWGRootForm(self): |
def manage_addMPIWGRootForm(self): |
"""form for adding the root""" |
"""form for adding the root""" |