[Zope] Problème avec un produit python sous Zope
bonjour à tous
voici le code de mes deux fichiers composant mon produit Zope
__init__.py :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
import ZHelloWorld
meta_types=(
{
'name' : 'ZHelloWorld',
'action' : 'manage_addZHelloWorldForm' },
)
methods={
'manage_addZHelloWorldForm' : ZHelloWorld.addZHelloWorldForm,
'manage_addZHelloWorld' : ZHelloWorld.addZHelloWorld,
}
__ac_permissions__=(('Add ZHelloWorld', ('addZHelloWorldForm', 'addZHelloWorld')),)
misc_={
'ZHelloWorldIcon' : ImageFile('www/ZHelloWorldIcon.GIF', globals()),
} |
ZHelloWorld.py
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
import Globals
from Globals import HTMLFile
from OFS import SimpleItem
class ZHelloWorld(SimpleItem.Item) :
"""Produit pour appredre"""
meta_type='Hello, World'
manage_options=(
{'label' : 'View', 'action' : 'render'},
)
def addZHelloWorldForm(self) :
return HTMLFile('dtml/ZHelloWorldaddForm', globals())
def __init__(self, id) :
"""Constructeur, méthode d'initialisation"""
self.id=id
def __call__(self, client=None, REQUEST={}, RESPONSE=None, **kw) :
""" __call__() -> string. Méthode appelée lors de l'invocation par <dtml-var >. Chargé de renvoyer la chaîne à afficher."""
return self.render()
def manage_addZHelloWorld(self, id, RESPONSE=None) :
"""manage_addZHelloWorld() -> nothing. Insère l'objet dans son conteneur et retourne la page index_html"""
self._setObject(id, ZHelloWorld(id))
RESPONSE.redirect('index_html')
def render(self) :
"""render(self)-> string. Retourne la cahîne formatée en HTML"""
return "<b>Hello World !</b>" |
Toutes les bonnes idées sont les bienvenue
J'avais oublier le msg d'erreur
Traceback (most recent call last):
File "C:\Program Files\Zope-2.8.5-final\lib\python\OFS\Application.py", line 698, in import_product
product=__import__(pname, global_dict, global_dict, silly)
File "C:\Zope-Instance\Products\ZHelloWorld\__init__.py", line 10, in ?
methods={
AttributeError: 'module' object has no attribute 'addZHelloWorldForm'