[Zope] MVC pattern
Steve Hunter
Steve@hosys.com
Wed, 16 Jun 1999 01:00:43 -0400
Hello,
Does a template exist for implementing an MVC (VisualWorks Smalltalk) like
structure for
Products. The Product example I have shows inheriting Zope class info and
DTML info
into the "domain object". I'd like a pattern where the Python objects remain
clean, are
wrapped by a value model, and linked via the value model with a presentation
scheme (DTML). Some
code is presented below to the idea across but is not a suggested
implementation.
class DomainWrapper(
OFS.SimpleItem.Item,
Persistent,
Acquisition.Implicit,
AccessControl.Role.RoleManager,
):
# Specify definitions for tabs:
manage_options=(
{'label':'Properties', 'action':'manage_main'},
{'label':'View', 'action':''},
{'label':'Security', 'action':'manage_access'},
)
# Specify how individual operations add up to "permissions":
__ac_permissions__=(
('View management screens', ('manage_tabs','manage_main')),
('Change permissions', ('manage_access',) ),
('Change Persons', ('manage_edit',)),
('View', ('','manage_self_edit') ),
)
_domainObj = ''
index_html = HTMLFile('blank',globals())
def for(self,aDomainObject)
_domainObj = aDomainObject
def defaultHTML(self, aDTMLFile)
index_html = HTMLFile(aDTMLFile)
#end class DomainWrapper
class DomainObj:
#end class DomainObj
class Person(DomainObj):
_lname = ''
_fname = ''
_ssn = ''
def _init_(self, lastname, firstname,ssn ):
_lname = lastname
_fname = firstname
_ssn = ssn
#end class Person
p = Person(John,Smith,1112223333)
pdw = DomainWrapper.for(p)
pdw.defaultHTML('person.dtml')
regards,
Steve