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):
  constructors = (
   BBSExpert.Manage_AddBBSExpertForm, BBSExpert.Manage_AddBBSExpertAction

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

 # 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())


 <dtml-if id>
  <dtml-var id><br><br>

 <dtml-if title>
  <dtml-var title><br><br>

 <dtml-if content>
  <dtml-var content><br><br>


<title>Add BBSExpert Instance</title>

<body bgcolor="#FFFFFF">
 <form name="form" action="Manage_AddBBSExpertAction" method="post"><br>
                <input type="text" name="id:string" size="30" value="BBSExpert">

                BBSExpert Title:<br>
                <input type="text" name="title:string" size="30" value="MyBBS">

                <textarea name="content:text" cols="40" rows="8" wrap="virtual">Content here.</textarea>

                <input type="submit" value="  add  ">



<title>Manage BBSExpert</title>
<body bgcolor="#FFFFFF">

 <dtml-var manage_tabs>

 <form name="form" action="." method="post"><br>

  <input type="text" name="title:string" size="30" value="<dtml-var title>">

  <textarea name="content:text" cols="40" rows="8" wrap="virtual"><dtml-var content></textarea>

  <input type="submit" value="Change" name="manage_editAction:method">




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

BBSExpert = context
return BBSExpert.display()


Help me.
Thank you very much.

   코리아는 당신을 사랑합니다
신나는 게임, 반가운 친구, 그 모든 것이 이곳에!
대표 게임 메가 포탈   http://game.korea.com

Reply via email to