annotate MPIWGRoot_deleted_methods.py @ 50:e30a4bd074db

more cleaning up projects.
author casties
date Mon, 29 Apr 2013 20:34:17 +0200
parents 01b5265264b6
children d456fe185649
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
50
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
1 class MPIWGRoot_deleted:
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
2
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
3
33
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
4 def removeStopWords(self,xo):
1
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
5 """remove stop words from xo"""
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
6 if not hasattr(self,'_v_stopWords'):
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
7 self._v_stopWords=self.stopwords_en.data.split("\n")
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
8
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
9 x=str(xo)
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
10
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
11 strx=x.split(" ")
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
12
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
13 for tmp in strx:
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
14
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
15 if tmp.lower() in self._v_stopWords:
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
16 del strx[strx.index(tmp)]
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
17
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
18 return " ".join(strx)
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
19
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
20
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
21 def getGetNeighbourhood(self,obj, wordStr, length=100,tagging=True):
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
22 """finde umgebung um die worte in wordStr, zurueckgegeben wird eine Array mit den Umgebungen von Fundstellen der Worte
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
23 alle Tags werden entfernt, die Fundstellen werden mit <span class="found">XX</span> getaggt, die Umgebungen werden
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
24 case insensitive gesucht
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
25 @param wordStr: string mit Worten getrennt durch Leerzeichen, Phrasen sind mit " gekennzeichnet
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
26 "eine phrase", "*" bezeichnet wildcards und wird ignoriert"
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
27 @param length: optional, default wert 100, 2*length ist die groesse der Umgebung
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
28 @param tagging: optional default wert true, kein span tag wird erzweugt falls tag=false
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
29 """
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
30
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
31 ret=[] # nimmt das Array auf, dass spaeter zurueckgegeben wird
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
32 ranges=[] #Array mit tupeln x,y wobei x die Position des Anfang und y des Endes der i-ten Umgebung angiebt
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
33
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
34 wordStr=wordStr.lstrip().rstrip()
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
35
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
36 def isInRanges(nr,length):
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
37 """test ob eine gegeben Position nr schon irgendwo in einer Umgebung ist, gibt den Index des ersten Wertes aus ranges zurueck,
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
38 -1, wenn kein Treffer
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
39
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
40 @param nr: Position die geprueft werden soll
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
41 @param length: Laenge des Wortes das geprueft werden soll
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
42 """
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
43 for x in ranges:
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
44 if (x[0]<=nr) and (nr < (x[1]-length)):
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
45 return ranges.index(x)
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
46 return -1
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
47
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
48 # deal with phrases, in Phrasen werden die Leerzeichen durch "_" ersetzt.
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
49 def rep_empty(str):
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
50 x= re.sub(" ","_",str.group(0))
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
51 return re.sub("\"","",x)
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
52
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
53 wordStr=re.sub("\".*?\"", rep_empty,wordStr)#ersetze leerzeichen in " " durch "_" und loesche "
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
54
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
55 #deal with wildcards, for our purposes it is enough to delete the wildcard
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
56 wordStr=wordStr.replace("*","")
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
57
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
58 words=wordStr.split(" ")
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
59 #if not words is ListType:
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
60 # words=[words]
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
61
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
62
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
63 txtCache = self.en.getHarvestCache();
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
64 txt= txtCache.get(obj.absolute_url(),None)
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
65
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
66 if txt==None:
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
67
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
68 logging.debug("NO CACHE for: "+obj.absolute_url())
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
69 txt=obj.harvest_page(mode="slim")
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
70
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
71
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
72 if not txt:
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
73 return ret
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
74
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
75 soup = BeautifulSoup(txt)
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
76
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
77 comments = soup.findAll(text=lambda text:isinstance(text, Comment))
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
78 [comment.extract() for comment in comments]
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
79
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
80 txt = ''.join(soup.findAll(text=True))
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
81
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
82
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
83 #txt=re.sub("<.*?>", "", txt) # loesche alle Tags
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
84 for word in words:
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
85 word=re.sub("_"," ",word) # ersetze zurueck "_" durch " "
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
86 pos=0
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
87
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
88 n=txt.lower().count(word.lower()) # wie oft tritt das Wort auf
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
89
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
90 for i in range(n):
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
91 pos=txt.lower().find(word.lower(),pos)
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
92
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
93 if pos > 0:
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
94 x=max(0,pos-length)
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
95 y=min(len(txt),pos+length)
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
96
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
97
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
98 #is word already in one of the results
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
99 nr=isInRanges(pos,len(word))
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
100 if nr >=0:# word ist in einer schon gefunden Umgebung, dann vergroessere diese
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
101 x=min(ranges[nr][0],x)
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
102 y=max(ranges[nr][1],y)
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
103
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
104 str=txt[x:y]
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
105 if x!=0: #add dots if in the middle of text
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
106 str="..."+str
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
107
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
108 if y!=len(txt): #add dots if in the middle of text
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
109 str=str+"..."
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
110
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
111
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
112
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
113 if nr >=0: # word ist in einer schon gefunden Umgebung
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
114 ranges[nr]=(x,y) # neue Position der Umgebung
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
115
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
116 ret[nr]=str # neue Umgebung
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
117 else: # andernfalls neue Umgebung hinzufuegen
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
118 ranges.append((x,y))
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
119
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
120 ret.append(str)
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
121
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
122 pos=pos+len(word)
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
123 else:
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
124 break;
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
125
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
126 # now highlight everything
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
127 if tagging:
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
128 for x in range(len(ret)):
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
129 for word in words:
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
130 repl=re.compile(word,re.IGNORECASE)
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
131 ret[x]=repl.sub(""" <span class="found">%s</span>"""%word.upper(),ret[x])
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
132
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
133 return ret
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
134 def copyAllImagesToMargin(self):
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
135 """tranformiere alle Bilder in die Margins"""
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
136 projects=self.getTree()
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
137 ret=""
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
138 for project in projects:
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
139 proj=project[3]
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
140 try:
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
141 persons=proj.copyImageToMargin();
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
142 except:
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
143 logging.error("Cannnot do: %s"%repr(project))
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
144
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
145 def transformProjectsToId(self):
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
146 """trnasformiere zu ID, Hilfsfunktion die die alten Templates analysiert und mit der neuen Liste
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
147 verantwortlicher Personen versieht"""
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
148 projects=self.getTree()
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
149 ret=""
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
150 for project in projects:
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
151
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
152 proj=project[3]
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
153 persons=proj.identifyNames(proj.getContent('xdata_01'))
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
154 if not hasattr(proj,'responsibleScientistsList'):
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
155 proj.responsibleScientistsList=[]
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
156
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
157 for person in persons.items():
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
158
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
159 if len(person[1]) >1: #nicht eindeutig
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
160 ret+="nicht eindeutig --- %s: %s\n"%(proj.getId(),person[0])
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
161
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
162 elif len(person[1]) ==0: #kein eintrage
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
163 ret+="kein eintrag--- %s: %s\n"%(proj.getId(),person[0])
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
164 proj.responsibleScientistsList.append((person[0],""))
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
165 else:
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
166 proj.responsibleScientistsList.append((person[0],person[1][0].getObject().getKey()))
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
167
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
168 return ret
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
169
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
170
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
171 def harvestProjects(self):
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
172 """harvest"""
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
173 folder="/tmp"
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
174 try:
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
175 os.mkdir("/tmp/harvest_MPIWG")
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
176 except:
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
177 pass
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
178 founds=self.ZopeFind(self.aq_parent.projects,obj_metatypes=['MPIWGProject'],search_sub=1)
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
179 for found in founds:
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
180 txt=found[1].harvest_page()
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
181
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
182 if txt and (txt != ""):
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
183 name=found[0].replace("/","_")
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
184 fh=file("/tmp/harvest_MPIWG/"+name,"w")
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
185 fh.write(txt)
1f2760ed3efe indices geloescht
dwinter
parents:
diff changeset
186 fh.close()
33
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
187
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
188
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
189
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
190 def generateNameIndex(self):
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
191 """erzeuge einen index verwendeter personen"""
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
192 import psycopg
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
193 o = psycopg.connect('dbname=authorities user=dwinter password=3333',serialize=0)
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
194 results={}
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
195 print self.fulltext.historicalNames.items()
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
196 for nameItem in self.fulltext.historicalNames.items(): #gehe durch alle namen des lexikons
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
197
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
198 c = o.cursor()
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
199 name=nameItem[0]
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
200 print "check",name
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
201 c.execute("select lastname,firstname from persons where lower(lastname) = '%s'"%quote(name))
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
202 tmpres=c.fetchall()
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
203 firstnames=[result[1] for result in tmpres] # find all firstnames
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
204 if tmpres:
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
205 lastname=tmpres[0][0]
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
206
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
207 for found in self.fulltext({'names':name}):
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
208 if found.getObject().isActual():
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
209 for nh in found.getObject().getGetNeighbourhood(name, length=50,tagging=False): #hole umgebung
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
210 #schaue nun ob der vorname hinter oder vor dem name ist
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
211 position=nh.find(lastname)
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
212 # vorher
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
213 #print "NH",nh
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
214 bevorS=nh[0:position].split()
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
215 #print "BV",bevorS
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
216 if len(bevorS)>1:
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
217 try:
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
218 bevor=[bevorS[-1],bevorS[-2]]
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
219 except:
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
220 bevor=[bevorS[0]]
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
221 else:
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
222 bevor=[]
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
223 #nachher
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
224 behindS= re.split("[,|;| ]",nh[position:])
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
225 #print "BH",behindS
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
226 if len(behindS)>2:
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
227 try:
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
228 behind=behindS[1:3]
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
229 except:
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
230 behind=[bevorS[1]]
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
231 else:
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
232 behind=[]
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
233 for firstname in firstnames:
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
234 if firstname in bevor+behind: #Namen wie mit Adelspraedikaten werden so erstmal nich gefunden
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
235 id="%s,%s"%(lastname,firstname)
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
236 if not results.has_key(id):
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
237 results[id]=[]
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
238 objId=found.getObject().getId()
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
239 if not (objId in results[id]):
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
240 print "d %s for %s"%(id,objId)
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
241 results[id].append(objId)
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
242 self.nameIndex=results
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
243 return results
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
244
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
245 def editNameIndexHTML(self):
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
246 """edit the name index"""
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
247 if not hasattr(self,'nameIndexEdited'): # falls editierter index noch nicht existiert, kopiere automatisch erstellten
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
248 self.nameIndexEdited=copy.copy(self.nameIndex)
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
249 print "huh"
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
250 #self.nameIndexEdited=copy.copy(self.nameIndex)
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
251 #print self.nameIndexEdited
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
252 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editHistoricalNames.zpt')).__of__(self)
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
253 return pt()
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
254
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
255 def getNamesInProject(self,projectId):
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
256 """get all names ofnameIndexEdited which are references in projec with projectId"""
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
257
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
258 ret=[]
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
259 for name in self.nameIndexEdited.keys():
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
260 if projectId in self.nameIndexEdited[name]:
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
261 ret.append(name)
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
262
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
263 return ret
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
264
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
265 def editNameIndex(self,RESPONSE=None,name=None,occurrances=None,submit=None):
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
266 """edit the index"""
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
267 nI=self.nameIndexEdited # mI introduced to make sure that changes to nameIndexEdited are know to ZODB
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
268 if submit=="delete":
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
269
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
270
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
271 dh=getattr(self,'deletedHistoricalNames',{})
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
272
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
273 if type(dh) is ListType:
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
274 dh={}
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
275 if not dh.has_key(name):
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
276 dh[name]=occurrances.split("\n")
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
277 else:
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
278 dh[name]+=occurrances.split("\n")
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
279
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
280 self.deletedHistoricalNames=dh
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
281
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
282 del self.nameIndexEdited[name]
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
283
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
284
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
285 elif (submit=="change"):
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
286
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
287 nI[name]=occurrances.split("\n")[0:]
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
288
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
289 elif (submit=="add"):
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
290 if not nI.has_key(name):
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
291 nI[name]=occurrances.split("\n")
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
292 else:
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
293 nI[name]+=occurrances.split("\n")
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
294
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
295 self.nameIndexEdited=nI
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
296
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
297
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
298 if RESPONSE is not None:
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
299 RESPONSE.redirect('editNameIndexHTML')
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
300
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
301
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
302
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
303 def restoreIndex(self):
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
304 """restore"""
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
305 self.nameIndexEdited=self.nameIndex
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
306 return "done"
50
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
307
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
308 def getProjectsOfMembers(self,date=None):
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
309 """give tuple member /projects"""
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
310 ret=[]
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
311 members=self.getAllMembers()
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
312 logging.debug("X %s"%repr(members))
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
313 #return str(members)
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
314 for x in members:
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
315 #logging.debug("X %s"%repr(x))
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
316 projects=self.getProjectsOfMember(key=x[1],date=date)
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
317 if len(projects)>0:
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
318 ret.append((x[0],projects))
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
319
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
320 return ret
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
321
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
322 def getProjectsOfMember(self,key=None,date=None,onlyArchived=1,onlyActive=1):
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
323 """get projects of a member
33
01b5265264b6 more work on projects.
casties
parents: 1
diff changeset
324
50
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
325 @param key: (optional) Key zur Idenfikation des Benutzer
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
326 @param date: (optional) Version die zum Zeitpunkt date gueltig war
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
327 @param onlyArchived:
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
328 onlyArchived=0: alle Projekte
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
329 onlyArchived= 1 : nur aktuelle Projekte
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
330 onlyArchived = 2: nur archivierte Projekte
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
331 """
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
332 # TODO: Die ganze Loesung
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
333 def sortP(x,y):
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
334 """sort by sorting number"""
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
335 return cmp(x.WEB_title,y.WEB_title)
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
336
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
337 ret=[]
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
338 if key:
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
339 logging.debug("MPIWGROOT (getProjectsOfMember):"+key)
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
340 proj=self.ProjectCatalog({'getPersonKeyList':utf8ify(key)})
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
341 else:
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
342 return ret # key muss definiert sein
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
343
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
344 #logging.debug("MPIWGROOT (getProjectsOfMember):"+repr(proj))
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
345 if proj:
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
346 proj2=[]
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
347 for x in proj:
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
348 #logging.error("proj:%s"%repr(x.getPath()))
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
349 if (not getattr(x.getObject(),'invisible',None)) and (getattr(x.getObject(),'archiveTime','')==''):
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
350 proj2.append(x)
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
351
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
352 else:
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
353 proj2=[]
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
354
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
355
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
356
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
357 proj2.sort(sortP)
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
358
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
359 projectListe=[]
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
360 #logging.error("getprojectsofmember proj2: %s"%repr(proj2))
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
361 for proj in proj2:
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
362 obj=proj.getObject()
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
363 add=False
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
364 if onlyArchived==1: #nur aktuell projecte
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
365 if not obj.isArchivedProject():
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
366 add=True
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
367 elif onlyArchived==2: #nur archivierte
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
368 if obj.isArchivedProject():
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
369 add=True
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
370 else: #alle
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
371 add=True
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
372
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
373 if onlyActive==1: #nur active projecte
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
374 if obj.isActiveProject():
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
375 add=add & True
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
376 else:
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
377 add=add & False
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
378
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
379 elif onlyArchived==2: #nur nicht aktvive
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
380 if not obj.isActiveProject():
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
381 add=add & True
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
382 else: #alle
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
383 add=add & True
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
384
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
385 if add:
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
386 projectListe.append(obj)
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
387
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
388 #logging.error("getprojectsofmember projectliste: %s"%repr(projectListe))
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
389 return projectListe
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
390
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
391
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
392 def givePersonList(self,name):
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
393 """check if person is in personfolder and return list of person objects"""
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
394
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
395 splitted=name.split(",")
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
396 if len(splitted)==1:
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
397 splitted=name.lstrip().rstrip().split(" ")
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
398 splittedNew=[split.lstrip() for split in splitted]
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
399
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
400 if splittedNew[0]=='':
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
401 del splittedNew[0]
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
402 search=string.join(splittedNew,' AND ')
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
403
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
404 if not search=='':
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
405 proj=self.MembersCatalog({'title':search})
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
406
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
407 if proj:
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
408 return [[x.lastName,x.firstName] for x in proj]
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
409 else:
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
410 return []
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
411
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
412 ## splitted=name.split(",") # version nachname, vorname...
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
413 ## if len(splitted)>1:
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
414 ## lastName=splitted[0]
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
415 ## firstName=splitted[1]
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
416 ## else:
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
417 ## splitted=name.split(" ") #version vorname irgenwas nachnamae
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
418
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
419 ## lastName=splitted[len(splitted)-1]
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
420 ## firstName=string.join(splitted[0:len(splitted)-1])
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
421
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
422 ## objs=[]
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
423
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
424 #print self.members
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
425 ## for x in self.members.__dict__:
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
426 ## obj=getattr(self.members,x)
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
427 ## if hasattr(obj,'lastName') and hasattr(obj,'firstName'):
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
428
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
429 ## if (re.match(".*"+obj.lastName+".*",lastName) or re.match(".*"+lastName+".*",obj.lastName)) and (re.match(".*"+obj.firstName+".*",firstName) or re.match(".*"+firstName+".*",obj.firstName)):
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
430
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
431 ## objs.append((obj,lastName+", "+firstName))
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
432
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
433
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
434 ## return objs
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
435
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
436
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
437 def personCheck(self,names):
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
438 """all persons for list"""
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
439 #print "names",names
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
440 splitted=names.split(";")
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
441 ret={}
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
442 for name in splitted:
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
443
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
444 if not (name==""):
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
445 try:
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
446 ret[name]=self.givePersonList(name)
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
447 except:
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
448 """NOTHIHN"""
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
449 #print "RET",ret
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
450 return ret
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
451
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
452 def giveCheckList(self,person,fieldname):
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
453 """return checklist"""
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
454 #print "GCL",fieldname
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
455 if fieldname=='xdata_01':
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
456 x=self.personCheck(person.getContent(fieldname))
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
457 #print "GCLBACKX",x
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
458 return x
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
459
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
460
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
461 # TODO: do we need this here?
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
462 def isCheckField(self,fieldname):
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
463 """return chechfield"""
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
464 return (fieldname in checkFields)
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
465
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
466
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
467
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
468 def sortResults(self,results):
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
469 """search the catalog and give results back sorted by meta_type"""
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
470 ret = {}
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
471 logging.debug(results())
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
472 for result in results():
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
473 metaType = result.meta_type
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
474 resultList= ret.get(metaType,[])
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
475 resultList.append(result)
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
476 ret[metaType]=resultList
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
477
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
478 logging.debug(ret)
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
479 return ret
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
480
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
481 # TODO: remove
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
482 def isActiveMember(self,key):
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
483 """tested ob Mitarbeiter key ist aktiv"""
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
484 key=utf8ify(key)
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
485 ret=getAt(self.ZSQLInlineSearch(_table='personal_www',
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
486 _op_key='eq',key=key,
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
487 _op_publish_the_data='eq',
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
488 publish_the_data='yes'), 0)
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
489
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
490 logging.info("MPIWGROOT ACTIVE_MEMBER %s"%ret)
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
491 if ret:
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
492 return True
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
493 else:
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
494 return False
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
495
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
496 # TODO: remove
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
497 def isActual(self,project):
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
498 """checke if project is actual"""
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
499 actualTime=time.localtime()
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
500
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
501 if hasattr(project,'getObject'): #obj ist aus einer catalogTrefferList
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
502 obj=project.getObject()
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
503 else:
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
504 obj=project
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
505
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
506 if getattr(obj,'archiveTime',actualTime)< actualTime:
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
507 return False
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
508 else:
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
509 return True
e30a4bd074db more cleaning up projects.
casties
parents: 33
diff changeset
510