Mercurial > hg > MPIWGWeb
comparison MPIWGLink.py @ 0:bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
author | casties |
---|---|
date | Thu, 10 Jan 2013 17:52:13 +0100 |
parents | |
children | ee79f6ba8d01 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:bca61e893fcc |
---|---|
1 from Products.PageTemplates.PageTemplateFile import PageTemplateFile | |
2 from Products.PageTemplates.PageTemplate import PageTemplate | |
3 from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate | |
4 from Products.ZSQLExtend.ZSQLExtend import ZSQLExtendFolder | |
5 from Products.ZCatalog.CatalogPathAwareness import CatalogAware | |
6 from OFS.Image import Image | |
7 from Globals import package_home | |
8 import urllib | |
9 import MPIWGStaff | |
10 import string | |
11 import re | |
12 import os | |
13 from types import * | |
14 import logging | |
15 import xmlhelper # Methoden zur Verwaltung der projekt xml | |
16 from OFS.SimpleItem import SimpleItem | |
17 from OFS.Folder import Folder | |
18 from Products.ZSQLMethods.SQL import SQLConnectionIDs | |
19 from AccessControl import ClassSecurityInfo | |
20 from bibliography import * | |
21 import time | |
22 import xml.dom.minidom | |
23 import sys | |
24 from Ft.Xml.XPath import Evaluate | |
25 from Ft.Xml.XPath.Context import Context | |
26 from Ft.Xml.Domlette import NonvalidatingReader,PrettyPrint, Print | |
27 from Ft.Xml import EMPTY_NAMESPACE | |
28 import copy | |
29 import updatePersonalWWW | |
30 import MPIWGStaff | |
31 | |
32 from MPIWGHelper import * | |
33 class MPIWGLink(SimpleItem): | |
34 """create a symbolic link to another page""" | |
35 | |
36 meta_type="MPIWGLink" | |
37 | |
38 def isActiveItem(self): | |
39 """teste ob ausgewaehlt""" | |
40 #url1 beim link anstelle von url1, da link jeweils index_html als url hat. | |
41 if self.absolute_url()==self.REQUEST['URL1']: | |
42 return "aktiv" | |
43 else: | |
44 return "" | |
45 | |
46 def __init__(self,id,link,title='',weight=''): | |
47 """init mpiwglink""" | |
48 self.id=id | |
49 self.link=link | |
50 self.title=title | |
51 self.weight=weight | |
52 | |
53 def getObj(self): | |
54 """bekomme original""" | |
55 ## objpath=self.link.replace("/",".") | |
56 ## if objpath[0]!=".": | |
57 ## objpath="."+objpath | |
58 | |
59 ## print objpath | |
60 ## return eval("self"+objpath) | |
61 | |
62 | |
63 splitted=self.link.lstrip().split("/") | |
64 obj=self | |
65 for x in splitted: | |
66 if not x=="": | |
67 obj=getattr(obj,x) | |
68 | |
69 return obj | |
70 | |
71 def getWeight(self): | |
72 if self.linkWeight and self.linkWeight!="": | |
73 return self.linkWeight | |
74 else: | |
75 return self.getObj().weight | |
76 | |
77 manage_options=( | |
78 {'label':'main config','action':'changeLinkForm'}, | |
79 )+SimpleItem.manage_options | |
80 | |
81 | |
82 def changeLinkForm(self): | |
83 """change MPIWG link""" | |
84 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','MPIWGLinkChange.zpt')).__of__(self) | |
85 return pt() | |
86 | |
87 def changeLink(self,link,title,weight,RESPONSE=None): | |
88 """change links""" | |
89 self.link=link | |
90 self.title=title | |
91 self.weight=weight | |
92 | |
93 if RESPONSE is not None: | |
94 RESPONSE.redirect('manage') | |
95 | |
96 def index_html(self,**argv): | |
97 """index""" | |
98 | |
99 | |
100 | |
101 try: | |
102 return self.getObj().pt_render(extra_context={'here':self}) | |
103 except: | |
104 self.REQUEST.RESPONSE.redirect(self.getObj().absolute_url()) | |
105 | |
106 | |
107 | |
108 def manage_addMPIWGLinkForm(self): | |
109 """Form for adding link""" | |
110 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt/AddMPIWGLink.zpt')).__of__(self) | |
111 return pt() | |
112 | |
113 def manage_addMPIWGLink(self,id,link,title,weight,RESPONSE=None): | |
114 """add link""" | |
115 newObj=MPIWGLink(id,link,title,weight) | |
116 | |
117 self._setObject(id,newObj) | |
118 | |
119 if RESPONSE is not None: | |
120 RESPONSE.redirect('manage_main') | |
121 |