Greetings everybody, I've tried to find some information on this subject by using Google, with no success. Therefore I ask it here, and if I've selected the wrong mailing list please let me know and accept my appologies. I need to develop a Zope product whose logic-part is to be left untouched but whose presentation parts (DTML methods, etc.) should be customizable. I'll give a little example to clearify: Let's say I write a guestbook product. This product has a default user interface which means that I can, if I wish, just add a guestbook product to the customer's folder and that's it. Unfortunately we're seldom that lycky. Perhaps the customer wants the guestbook in another language, or "embedded" into his/her original website. To do this I'll have to override the default presentation pages somehow. The management screens can stay as they were. What is the best approach? Thanks in advance, -Petter- -- Petter Holmström Civare, Åbo Akademi University Axelia, Biskopsgatan 8, Room 339 Tel: +358 2 215 3508 GSM: +358 40 8395765 Email: petter.holmstrom@abo.fi
I'd provide a default DTMLMethod | PageTemplate file and check for a ZODB based DTMLMethod | PageTemplate object Sth like def render(self, <request, args etc.>): template = getattr(self, 'customized_pt', None) if template is None: template = self.default_pt return template(<your arguments>) Petter Holmström wrote:
Greetings everybody,
I've tried to find some information on this subject by using Google, with no success. Therefore I ask it here, and if I've selected the wrong mailing list please let me know and accept my appologies.
I need to develop a Zope product whose logic-part is to be left untouched but whose presentation parts (DTML methods, etc.) should be customizable. I'll give a little example to clearify:
Let's say I write a guestbook product. This product has a default user interface which means that I can, if I wish, just add a guestbook product to the customer's folder and that's it. Unfortunately we're seldom that lycky. Perhaps the customer wants the guestbook in another language, or "embedded" into his/her original website. To do this I'll have to override the default presentation pages somehow. The management screens can stay as they were. What is the best approach?
Thanks in advance,
-Petter-
On pe, 2003-12-05 at 13:03, Peter Sabaini wrote:
I'd provide a default DTMLMethod | PageTemplate file and check for a ZODB based DTMLMethod | PageTemplate object
Sth like
def render(self, <request, args etc.>): template = getattr(self, 'customized_pt', None) if template is None: template = self.default_pt return template(<your arguments>) ^^^^ What kind of arguments are we talking about here?
This code: def index_html(self, REQUEST): template = DTMLFile( 'dtml/my_dtml_file', globals() ) return template(self, REQUEST) results in the following error message: Error Type: AttributeError Error Value: aq_parent I've looked in Google and found several posts about similar problems, but I have not been able to find the solution to this particular problem. Thanks in advance, -Petter- -- Petter Holmström Civare, Åbo Akademi University Axelia, Biskopsgatan 8, Room 339 Tel: +358 2 215 3508 GSM: +358 40 8395765 Email: petter.holmstrom@abo.fi
Petter Holmström wrote:
On pe, 2003-12-05 at 13:03, Peter Sabaini wrote:
I'd provide a default DTMLMethod | PageTemplate file and check for a ZODB based DTMLMethod | PageTemplate object
Sth like
def render(self, <request, args etc.>): template = getattr(self, 'customized_pt', None) if template is None: template = self.default_pt return template(<your arguments>)
^^^^ What kind of arguments are we talking about here?
These are template specific (ie. different for DTML and PageTemplates). For DTML this eg. could be: template(client=self, REQUEST=self.REQUEST, foo=bar, spam=egg) foo and spam are additional (optional) keyword args you might want to pass to the template In lib/python/OFS/DTMLMethod.py , see DTMLMethod.__call__() for details
This code:
def index_html(self, REQUEST): template = DTMLFile( 'dtml/my_dtml_file', globals() ) return template(self, REQUEST)
results in the following error message:
Error Type: AttributeError Error Value: aq_parent
I've looked in Google and found several posts about similar problems, but I have not been able to find the solution to this particular problem.
Thanks in advance,
-Petter-
On pe, 2003-12-05 at 14:48, Petter Holmström wrote:
On pe, 2003-12-05 at 13:03, Peter Sabaini wrote:
I'd provide a default DTMLMethod | PageTemplate file and check for a ZODB based DTMLMethod | PageTemplate object
Sth like
def render(self, <request, args etc.>): template = getattr(self, 'customized_pt', None) if template is None: template = self.default_pt return template(<your arguments>) ^^^^ What kind of arguments are we talking about here?
This code:
def index_html(self, REQUEST): template = DTMLFile( 'dtml/my_dtml_file', globals() ) return template(self, REQUEST)
results in the following error message:
Error Type: AttributeError Error Value: aq_parent
I found a solution to the problem: def index_html(self, REQUEST): template = DTMLFile( self.private_views['view'], globals() ).__of__(self) return template() Now I just have to figure out why this works... :-) -Petter- -- Petter Holmström Civare, Åbo Akademi University Axelia, Biskopsgatan 8, Room 339 Tel: +358 2 215 3508 GSM: +358 40 8395765 Email: petter.holmstrom@abo.fi
Petter Holmström wrote:
On pe, 2003-12-05 at 14:48, Petter Holmström wrote:
On pe, 2003-12-05 at 13:03, Peter Sabaini wrote:
I'd provide a default DTMLMethod | PageTemplate file and check for a ZODB based DTMLMethod | PageTemplate object
Sth like
def render(self, <request, args etc.>): template = getattr(self, 'customized_pt', None) if template is None: template = self.default_pt return template(<your arguments>)
^^^^ What kind of arguments are we talking about here?
This code:
def index_html(self, REQUEST): template = DTMLFile( 'dtml/my_dtml_file', globals() ) return template(self, REQUEST)
results in the following error message:
Error Type: AttributeError Error Value: aq_parent
I found a solution to the problem:
def index_html(self, REQUEST): template = DTMLFile( self.private_views['view'], globals() ).__of__(self) return template()
Now I just have to figure out why this works... :-)
Because the DTMLFile misses Acquisition wrappers otherwise. I've always made the template a class attribute -- parsing DTML is a rather expensive process, and should be avoided unless necessary Eg. class MyProduct(...): template = DTMLFile('dtml/my_dtml_file', globals()) def index_html(self, REQUEST): return self.template(client=self, REQUEST=REQUEST)
-Petter-
From: "Petter Holmström" <petter.holmstrom@abo.fi>
def index_html(self, REQUEST): template = DTMLFile( self.private_views['view'], globals() ).__of__(self) return template()
Now I just have to figure out why this works... :-)
Because the things you need are acquired, and to acquire you need to wrap the object. This is done automatically if it's an attribute, but in this case it isn't.
From: "Petter Holmström" <petter.holmstrom@abo.fi>
Let's say I write a guestbook product. This product has a default user interface which means that I can, if I wish, just add a guestbook product to the customer's folder and that's it. Unfortunately we're seldom that lycky. Perhaps the customer wants the guestbook in another language, or "embedded" into his/her original website. To do this I'll have to override the default presentation pages somehow. The management screens can stay as they were. What is the best approach?
Well, step one is to make sure that all the logic is the part of the product python classes, and that no logic is in the DTML. A godo way of doing this is using ZPT where putting anything else than display logic in the templates automatically becomes painful. :-) Step two is to make sure you have a good flexible API to call the logic. After that, step three is to make the display methods (DTML or ZPT). The customer adaptation is then just a question of making new templates. Step four is optional, and that is to make parts reusable, but still replaceable. This is hard to do in pure Zope, and requires some sort of "templating system". CMF's portal_skins is one. //Lennart
Lennart Regebro wrote:
From: "Petter Holmström" <petter.holmstrom@abo.fi>
Let's say I write a guestbook product. This product has a default user interface which means that I can, if I wish, just add a guestbook product to the customer's folder and that's it. Unfortunately we're seldom that lycky. Perhaps the customer wants the guestbook in another language, or "embedded" into his/her original website. To do this I'll have to override the default presentation pages somehow. The management screens can stay as they were. What is the best approach?
Well, step one is to make sure that all the logic is the part of the product python classes, and that no logic is in the DTML. A godo way of doing this is using ZPT where putting anything else than display logic in the templates automatically becomes painful. :-)
Step two is to make sure you have a good flexible API to call the logic.
After that, step three is to make the display methods (DTML or ZPT). The customer adaptation is then just a question of making new templates.
Step four is optional, and that is to make parts reusable, but still replaceable. This is hard to do in pure Zope, and requires some sort of "templating system". CMF's portal_skins is one.
The CMF skin system (Filesystem Directory View) is available outside CMF in the FileSystemSite product. That seems like the right way to do skinning to me. --jcc -- "My point and period will be throughly wrought, Or well or ill, as this day's battle's fought."
On 12/5/03 11:27 AM, "J. Cameron Cooper" <jccooper@jcameroncooper.com> wrote:
Lennart Regebro wrote:
From: "Petter Holmström" <petter.holmstrom@abo.fi>
Let's say I write a guestbook product. This product has a default user interface which means that I can, if I wish, just add a guestbook product to the customer's folder and that's it. Unfortunately we're seldom that lycky. Perhaps the customer wants the guestbook in another language, or "embedded" into his/her original website. To do this I'll have to override the default presentation pages somehow. The management screens can stay as they were. What is the best approach?
Well, step one is to make sure that all the logic is the part of the product python classes, and that no logic is in the DTML. A godo way of doing this is using ZPT where putting anything else than display logic in the templates automatically becomes painful. :-)
Step two is to make sure you have a good flexible API to call the logic.
After that, step three is to make the display methods (DTML or ZPT). The customer adaptation is then just a question of making new templates.
Step four is optional, and that is to make parts reusable, but still replaceable. This is hard to do in pure Zope, and requires some sort of "templating system". CMF's portal_skins is one.
The CMF skin system (Filesystem Directory View) is available outside CMF in the FileSystemSite product. That seems like the right way to do skinning to me.
I haven't integrated the full cmf skinning mechanism in filesystemsite as it entails architecture/instance space requirements for sites. currently filesystemsite is based purely based on fs directory views for managing site code/presentation on the fs. -kapil
kapil thangavelu wrote at 2003-12-5 11:44 -0800:
On 12/5/03 11:27 AM, "J. Cameron Cooper" <jccooper@jcameroncooper.com> wrote: ... I haven't integrated the full cmf skinning mechanism in filesystemsite as it entails architecture/instance space requirements for sites. currently filesystemsite is based purely based on fs directory views for managing site code/presentation on the fs.
There is "SkinnedFolder" for the "skinning mechanism": <http://www.dieter.handshake.de/pyprojects/zope> -- Dieter
participants (6)
-
Dieter Maurer -
J. Cameron Cooper -
kapil thangavelu -
Lennart Regebro -
Peter Sabaini -
Petter Holmström