-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 There seems to be a bug when trying to use mixins and PSP...
For example... I have some layout classes... BaseLayout, which overwrites writeHTML... it calls preLayout, writes some VERY basic html.. calls writeHTMLBody, then calls postLayout. SiteLayout overwrites writeHTMLBody ... which prints a bunch of layout html (tables and etc) and calls writeScreen I then have a security mixin called SecureMixIn... which has the method preLayout() Now.. using these classes.. the following works: from layout.SiteLayout import SiteLayout from screen.SecureMixIn import SecureMixIn class test2(SecureMixIn, SiteLayout): def writeScreen(self): self.writeln("Test") Where the preLayout method from SecureMixIn overwrites the one from SiteLayout... but the rest of SiteLayout gets used as expected. Now this page requires someone to be authenticated from just using the mixin. However.. the following PSP page does not work: <%@ page method = "writeScreen" %> <%@ page imports = "layout:SiteLayout:SiteLayout, screen:SecureMixIn:SecureMixIn" %> <%@ page extends = "SecureMixIn, SiteLayout" %> <%@ page indentType="braces" %> <psp:method name="title">return "Test page"</psp:method> Great! We are authorized! which gives the following error: AttributeError: class SecureMixIn has no attribute 'awake' Although I code add code to the PSP page to do the security check... thats kindof beond the point. The idea is to have as little code as possible in my psp page... and allow different functionality to be added through mixins. Security for example. Attached are most of the files involved. Of course... the SecureMixIn attached does not include code to handle my security... I am currently using a layout that extends SiteLayout to add security..... But using the mixin would be much prefered.... - -- Luke Holden eBI Solutions Main: (949) 387-5182 Email: [EMAIL PROTECTED] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE+G4e53q5xXfLZTQkRAgetAJ9bhBmdGog0h8F2ULJVERDDjSF4sQCfSDZk Mq+ua1n994/r/m/XUzW0gHA= =Gjg2 -----END PGP SIGNATURE-----
<%@ page method = "writeScreen" %> <%@ page imports = "layout:SiteLayout:SiteLayout, screen:SecureMixIn:SecureMixIn" %> <%@ page extends = "SecureMixIn, SiteLayout" %> <%@ page indentType="braces" %> <psp:method name="title">return "Test page"</psp:method> Great! We are authorized!
from layout.SiteLayout import SiteLayout from screen.SecureMixIn import SecureMixIn class test2(SecureMixIn, SiteLayout): def writeScreen(self): self.writeln("Test")
from WebKit.Page import Page class BaseLayout(Page): def awake(self, transaction): Page.awake(self, transaction) def preLayer(self): pass def postLayer(self): pass def writeHTML(self): self.preLayer() self.writeln(''' <html> <head> <title>''' + self.title() + '''</title> </head> <body>''') self.writeHTMLBody() self.writeln(''' </body> </html>''') self.postLayer() def writeScreen(self): """ Write screen contents inside the page""" self.writeln('<h1>No page content defined</h1>') def writeHTMLBody(self): self.writeScreen()
from BaseLayout import * class SiteLayout(BaseLayout): def writeHTMLBody(self): self.includeURL("navigation/nav") self.writeScreen()
class SecureMixIn: def preLayer(self): # Make sure user is authorised here pass