annotate MPIWGLink.py @ 212:7df88b4746b4

trying to fix #130: sortProjects funktioniert nicht https://it-dev.mpiwg-berlin.mpg.de/tracs/webpage/ticket/130
author casties
date Wed, 07 Aug 2013 10:58:17 +0200
parents ee79f6ba8d01
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
2 from OFS.SimpleItem import SimpleItem
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
3
159
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
4 import MPIWGHelper
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
5
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
6 class MPIWGLink(SimpleItem):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
7 """create a symbolic link to another page"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
8
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
9 meta_type="MPIWGLink"
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
10
159
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
11 manage_options=(
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
12 {'label':'main config','action':'changeLinkForm'},
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
13 )+SimpleItem.manage_options
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
14
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
15 changeLinkForm = PageTemplateFile('zpt/link/manage_change', globals())
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
16
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
17
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
18 def __init__(self,id,link,title='',weight=''):
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
19 """init mpiwglink"""
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
20 self.id=id
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
21 self.link=link
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
22 self.title=title
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
23 self.weight=weight
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
24
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
25
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
26 def getObj(self):
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
27 """bekomme original"""
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
28 splitted=self.link.lstrip().split("/")
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
29 obj=self
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
30 for x in splitted:
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
31 if not x=="":
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
32 obj=getattr(obj,x)
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
33
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
34 return obj
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
35
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
36
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
37 def index_html(self,**argv):
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
38 """index"""
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
39 try:
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
40 return self.getObj().pt_render(extra_context={'here':self})
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
41 except:
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
42 self.REQUEST.RESPONSE.redirect(self.getObj().absolute_url())
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
43
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
44
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
45 def isActiveItem(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
46 """teste ob ausgewaehlt"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
47 #url1 beim link anstelle von url1, da link jeweils index_html als url hat.
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
48 if self.absolute_url()==self.REQUEST['URL1']:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
49 return "aktiv"
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
50 else:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
51 return ""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
52
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
53 def getWeight(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
54 if self.linkWeight and self.linkWeight!="":
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
55 return self.linkWeight
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
56 else:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
57 return self.getObj().weight
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
58
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
59 def changeLink(self,link,title,weight,RESPONSE=None):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
60 """change links"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
61 self.link=link
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
62 self.title=title
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
63 self.weight=weight
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
64
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
65 if RESPONSE is not None:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
66 RESPONSE.redirect('manage')
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
67
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
68
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
69
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
70 def manage_addMPIWGLinkForm(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
71 """Form for adding link"""
159
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 0
diff changeset
72 pt=PageTemplateFile('zpt/link/manage_add_MPIWGLink.zpt', globals()).__of__(self)
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
73 return pt()
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
74
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
75 def manage_addMPIWGLink(self,id,link,title,weight,RESPONSE=None):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
76 """add link"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
77 newObj=MPIWGLink(id,link,title,weight)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
78
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
79 self._setObject(id,newObj)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
80
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
81 if RESPONSE is not None:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
82 RESPONSE.redirect('manage_main')
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
83