Hi,
I am trying to figure out ZPatterns and because I rather work with Python Products
when with Zclasses I am trying to convert the EmployZ product to Python.
So far I got half the way there, the Rack recognizes the DataSkin
And on newItem in the Specialist it a new slot gets created and I can see them and
their ID.
Now the problem is creating a Propertysheet in the DataSkin that gets stored in the
Rack.
I packet my work so far and put it on Zope.org:
http://www.zope.org/Members/johanc/ZPatterns/EmployX/EmployX-0.0.1.tgz
I look at the ZPattern Products that I know are out there, but they don't seem
help me any futher.
Regards,
Johan
Here's my to classes:
< EmployX (DataSkin)>
__doc__ = """EmployX product module.
See README.txt for more details."""
__version__ = '0.0.1'
from Globals import HTMLFile
from Globals import MessageDialog
from Globals import Persistent
import OFS.SimpleItem
import Acquisition
import AccessControl.Role
from Products.ZPatterns.DataSkins import DataSkin
#from Products.ZPatterns.PropertySheets import VirtualSheets
manage_addEmployXForm = HTMLFile('dtml/EmployXAdd', globals())
def manage_addEmployX(self, id, title='', REQUEST=None):
"""Add a EmployX to a folder."""
self._setObject(id, EmployX(id, title))
if REQUEST is not None:
return self.manage_main(self, REQUEST)
class EmployX(
DataSkin,
#VirtualSheets,
):
"""EmployX object.
"""
meta_type = 'EmployX'
# Necessary?
_isRackMountable = 1
#_properties=(
# {'id':'first', 'type': 'string'},
# {'id':'last', 'type': 'string'},
# {'id':'emp_id', 'type': 'string'},
# {'id':'salary', 'type': 'string'},
# )
manage_options = (
{'label': 'Edit', 'action': 'manage_main' },
{'label':'Debug','action':'debug'},
{'label': 'View', 'action': 'index_html'},
{'label': 'Security', 'action': 'manage_access'},
)
_v_manage_options_label_index =
ExtendedManagmentTabs.createManageIndex(manage_options=manage_options)
__ac_permissions__=(
('View management screens', ('debug','manage_tabs','manage_main')),
('Change permissions', ('manage_access',) ),
('Change EmployX' , ('manage_edit',) ),
('View EmployX', ('',) ),
)
def __init__(self,id):
"""initialise a new instance of BeingBoring"""
DataSkin.__init__(self,id)
def debug(self):
""" Print object's __dict__ """
result = ""
for k, v in self.__dict__.items():
result = "%s\n%s : %s" % (result, repr(k), repr(v))
return result
manage_main = HTMLFile('dtml/EmployXEdit', globals())
def manage_edit(self, title, REQUEST=None):
"""does this really need a doc string?"""
self.title = title
if REQUEST is not None:
return self.manage_main(self,REQUEST,management_view='Edit')
editInstance = HTMLFile('editInstance', globals())
editInstanceForm = HTMLFile('editInstanceForm', globals())
index_html = HTMLFile('index_html', globals())
def initialize(context):
"""Initialize the EmployX product.
"""
context.registerClass(
EmployX,
constructors = (
manage_addEmployXForm,
manage_addEmployX),
icon = 'www/item.gif'
)
# We need this so that this class will show up in the list of classes
# Customizers can customize. (Thanks Steve)
context.registerBaseClass(EmployX)
< EmployXManager(Specialist)>
__doc__ = """EmployXManager product module.
See README.txt for more details."""
__version__ = '0.0.1'
from Globals import HTMLFile
#from Globals import MessageDialog
#from Globals import Persistent
from Products.ZPatterns.Specialists import Specialist
manage_addEmployXManagerForm = HTMLFile('EmployXManagerAdd', globals())
def manage_addEmployXManager(self, id, title='', REQUEST=None):
"""Add a EmployXManager to a folder."""
self._setObject(id, EmployXManager(id, title))
if REQUEST is not None:
return self.manage_main(self, REQUEST)
class EmployXManager(Specialist):
"""Thing that manages EmployX"""
meta_type = "EmployXManager"
newItemForm = HTMLFile('newItemForm', globals())
index_html = HTMLFile('index_html_manager', globals())
def addNewItem(self,emp_id,REQUEST=None):
"""ttw"""
ob = self.newItem(emp_id)
#ob.addPropertySheet('Basic')
#ob.propertysheets.Basic.manage_changeProperties(REQUEST=REQUEST)
#if REQUEST.has_key('first'): ob.first = REQUEST['first']
#else: ob.first = ''
#if REQUEST.has_key('last'): ob.last = REQUEST['last']
#else: ob.last = ''
#if REQUEST.has_key('emp_id'): ob.emp_id = REQUEST['emp_id']
#else: ob.emp_id = ''
#if REQUEST.has_key('salary'): ob.salary = REQUEST['salary']
#else: ob.salary = ''
if REQUEST is not None:
return self.manage_main(self, REQUEST)
def initialize(context):
"""Initialize the EmployXManager product.
"""
context.registerClass(
EmployXManager,
constructors = (
manage_addEmployXManagerForm,
manage_addEmployXManager),
icon = 'www/item.gif'
)
_______________________________________________
Zope-Dev maillist - [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://lists.zope.org/mailman/listinfo/zope-announce
http://lists.zope.org/mailman/listinfo/zope )