[Zope-dev] manage_role : HELP
Jean-Louis BERLIET
jl.berliet@triade.tm.fr
Thu, 27 Apr 2000 12:01:51 +0200
"""Espace Projet"""
__version__='0.1'
import Globals, OFS.SimpleItem
from OFS.ObjectManager import ObjectManager
from OFS.PropertyManager import PropertyManager
from AccessControl.Role import RoleManager
from webdav.Collection import Collection
from OFS.FindSupport import FindSupport
from Globals import HTMLFile
def addImage(folder,id,file):
"""
A cause du bug sur manage_addImage
"""
f=open('%s/Products/%s' % (SOFTWARE_HOME,file),'rb')
contenu=f.read()
f.close
folder.manage_addImage(id,contenu,title='',precondition='',content_type=''
manage_addEspaceProjetForm=HTMLFile('EspaceProjetAdd', globals())
def manage_addEspaceProjet(self, id, title='',rang='',REQUEST=None):
"""
Ajoute un nouvel espace projet
"""
try: user=REQUEST['AUTHENTICATED_USER']
except: user=None
if (user is not None) and not (user.has_permission('Add Espace Projet',
self))
raise "Unauthorized", ("Vous n'êtes pas autorisé à ajouter un espace
projet."
ep=EspaceProjet()
ep.id=id
ep.title=title
ep.rang=rang
self._setObject(id, ep)
ep.manage_addUserFolder()
epw = HTMLFile('EspaceProjetView', globals())
ep.manage_addDTMLMethod('index_html', title='', file=epw)
# ajout d'un folder 'Images' s'il n'existe pas déjà dans un ancêtre
if REQUEST.PARENTS[0].meta_type<>'Espace projet':
ep.manage_addFolder('Images')
folderImages = ep._getOb('Images')
addImage(folderImages,'OpenBook.gif',
'EspaceProjet/Images/OpenBook.gif')
addImage(folderImages,'ClosedBook.gif',
'EspaceProjet/Images/ClosedBook.gif')
addImage(folderImages,'ajouter.gif',
'EspaceProjet/Images/ajouter.gif')
addImage(folderImages,'valide.gif', 'EspaceProjet/Images/valide.gif')
addImage(folderImages,'voir.gif', 'EspaceProjet/Images/voir.gif')
addImage(folderImages,'logoaplm.gif',
'EspaceProjet/Images/logoaplm.gif')
addImage(folderImages,'espaceProj35.jpg',
'EspaceProjet/Images/espaceProj35.jpg'
addImage(folderImages,'ft.gif', 'EspaceProjet/Images/ft.gif')
# ajout des en-tetes et pied de page
if REQUEST.PARENTS[0].meta_type<>'Espace projet':
etp=HTMLFile('standard_html_header', globals())
ep.manage_addDTMLMethod('standard_html_header', title='', file=etp)
pp=HTMLFile('standard_html_footer', globals())
ep.manage_addDTMLMethod('standard_html_footer', title='', file=pp)
if REQUEST is not None:
return self.manage_main(self, REQUEST, update_menu=1)
class EspaceProjet(ObjectManager, PropertyManager, RoleManager, Collection,
OFS.SimpleItem.Item, FindSupport):
def __init__(self):
if not ('Animateur' in self.userdefined_roles()):
self._addRole('Animateur')
self.manage_role('Animateur', ['View',
'View management screens',
'Add Folders',
'Delete objects',
'Access contents information',
'FTP access',
'Manage properties',
'Manage users',
'Undo changes',
'Add Espace Projet'
] )
if not ('Participant' in self.userdefined_roles()):
self._addRole('Participant')
if not ('Visiteur' in self.userdefined_roles()):
self._addRole('Visiteur')
meta_type='Espace projet'
_properties=({'id':'title', 'type': 'string'},
{'id':'rang', 'type': 'string'},)
manage_options=({'label':'Contents', 'action':'manage_main'},
{'label':'View', 'action':'index_html'},
{'label':'Properties', 'action':'manage_propertiesForm'
{'label':'Import/Export',
'action':'manage_importExportForm'
{'label':'Security', 'action':'manage_access'},
{'label':'Undo', 'action':'manage_UndoForm'},
{'label':'Find', 'action':'manage_findFrame',
'target':'manage_main'},
)
__ac_permissions__=(
('Add Espace Projet',('manage_addEspaceProjet',),
('Manager','Animateur')),
)
>Can you provide the entire Python File?
>
>Regards,
>Stephan
>--
>Stephan Richter - (901) 573-3308 - srichter@cbu.edu
>CBU - Physics & Chemistry; Framework Web - Web Design & Development
>PGP Key: 735E C61E 5C64 F430 4F9C 798E DCA2 07E3 E42B 5391
>
>
>