How to call the class in python file into zope script python.
Hi. This is Seoul in SouthKorea. First I excuse what I am not good at English. I made a simple product(named BBSExpert.py) by python, tested it, and succeeded. There is the display() class in the BBSExpert.py. I want to call this class (display() is located in the BBSExpert.py) into zope base(ex. Script (python)). These files are what I made. ************************************************************** 1. __init__.py import BBSExpert def initialize(context): """ """ context.registerClass( BBSExpert.BBSExpert, constructors = ( BBSExpert.Manage_AddBBSExpertForm, BBSExpert.Manage_AddBBSExpertAction ), icon=None ) *********************************************************************** 2. BBSExpert.py (display() class is located in this file.) from Globals import HTMLFile from Globals import MessageDialog from Globals import Persistent from Globals import DTMLFile import OFS.SimpleItem import Acquisition import AccessControl.Role import test def Manage_AddBBSExpertAction(self, id='BBSExpert', title='Title here', content='Content here.', REQUEST=None): """ Add a BBSExpert to a folder. """ self._setObject(id, BBSExpert(id, title, content)) if REQUEST is not None: return self.manage_main(self, REQUEST) # Get user id from this form Manage_AddBBSExpertForm = DTMLFile('www/Manage_AddBBSExpertForm', globals()) class BBSExpert( OFS.SimpleItem.Item, # A simple Principia object. Not Folderish. Persistent, # Make us persistent. Yaah! Acquisition.Implicit, # Let us use our parent's variables and methods. AccessControl.Role.RoleManager # Security manager. ): """ BBSExpert Product """ meta_type = 'BBSExpert' manage_options = ( {'label': 'Properties', 'action': 'manage_editForm',}, {'label': 'View', 'action': 'index_html',}, ) def __init__(self, id, title, content): "Inits the product with default values" self.id = id self.title = title self.content = content def manage_editAction(self, title, content, RESPONSE=None): "Changes the product values" self.title = title self.content = content self._p_changed = 1 RESPONSE.redirect('manage_editForm') # The web pages that shows content. Put your own in the www folder. def index_html(self): "used to view content of the object" return """<html><body>2pu hahaha</body></html>""" def display(self): "used to view content of the object" return """<html><body> We are the world</body></html>""" # Used to view content of the object #index_html = DTMLFile('www/index_html', globals()) # Edit the content of the object manage_editForm = DTMLFile('www/manage_editForm', globals()) Index_html.dtml******************************************** <dtml-if id> <b>ID:</b><br> <dtml-var id><br><br> </dtml-if> <dtml-if title> <b>Title:</b><br> <dtml-var title><br><br> </dtml-if> <dtml-if content> <b>Content:</b><br> <dtml-var content><br><br> </dtml-if> Manage_AddBBSExpertForm.dtml*************************************** <html> <head> <title>Add BBSExpert Instance</title> </head> <body bgcolor="#FFFFFF"> <form name="form" action="Manage_AddBBSExpertAction" method="post"><br> id:<br> <input type="text" name="id:string" size="30" value="BBSExpert"> <br><br> BBSExpert Title:<br> <input type="text" name="title:string" size="30" value="MyBBS"> <br><br> Content:<br> <textarea name="content:text" cols="40" rows="8" wrap="virtual">Content here.</textarea> <br><br> <input type="submit" value=" add "> </form> </body> </html> Manage_EditForm.dtml**************************************************** * <html> <head> <title>Manage BBSExpert</title> </head> <body bgcolor="#FFFFFF"> <dtml-var manage_tabs> <form name="form" action="." method="post"><br> BBSTitle:<br> <input type="text" name="title:string" size="30" value="<dtml-var title>"> <br><br> Content:<br> <textarea name="content:text" cols="40" rows="8" wrap="virtual"><dtml-var content></textarea> <br><br> <input type="submit" value="Change" name="manage_editAction:method"> </form> </body> </html> ************************************************************************ * 3. Examplecode.txt (This part what I failed actually.) (In Example.txt I could not return the display() class. How could I call the display()class into Script (Python) in zope management framework.) # Example code: # Import a standard function, and get the HTML request and response objects. from Products.PythonScripts.standard import html_quote request = container.REQUEST RESPONSE = request.RESPONSE BBSExpert = context return BBSExpert.display() ************************************************************************ **** Help me. Thank you very much. <http://www.korea.com> 코리아는 당신을 사랑합니다 --------------------------------------- 신나는 게임, 반가운 친구, 그 모든 것이 이곳에! 대표 게임 메가 포탈 http://game.korea.com
participants (1)
-
박 재성