[Plone-Users] access limited to method defined in view

1 view
Skip to first unread message

i00

unread,
Dec 31, 2009, 1:38:58 PM12/31/09
to plone...@lists.sourceforge.net
I am trying to call a template(morehome.pt) from a class inheriting PloneKSSView(xtra).
It is successful as long as i am not accessing any functions defined in the view class (ie, if i call bingo() in the template i am getting error as mentioned below).

When i try to render a pt file i am getting an error in the pdb saying
(Pdb) self.template()
*** Unauthorized: You are not allowed to access 'bingo' in this context
(Pdb)

in firebug console i am getting (i am logged in though)
http://localhost:8080/news/acl_users/credentials_cookie_auth/require_login?came_from=http%3A//localhost%3A8080/news/morenews%3FkukitTimeStamp%3D1262284189261

any help will be really great, i am pinned down on this for a while :-)

class moreView(BrowserView):

template = ViewPageTemplateFile("morehome.pt")
def __call__(self):
pdb.set_trace()
return self.template()
def bingo(self):
return "worked"

class DynamicHome(PloneKSSView):

@kssaction
def xtra(self,count):
print count
alsoProvides(self,IViewView)
ksscore = self.getCommandSet('core')
zopecommands = self.getCommandSet('zope')
selector = ksscore.getHtmlIdSelector("more-news-box")
#pdb.set_trace()
context = aq_inner(self.context)
request = aq_inner(self.request)
pdb.set_trace()
moreHtml = moreView(self.context, self.request).__call__()
print moreHtml
#replyhtml = "Request from "+more+" is<b><i> accepted<i><b>"
ksscore.replaceHTML(selector,moreHtml,withKssSetup='True')

########### more.pt ###########
<div id="just_an_id">
Hello

XXXyyyZZZ
<span tal:content="view/bingo">Nope</span>

</div>

######### configure.zcml ##########
<browser:page
for="*"
name="morenews"
class=".homepage.DynamicHome"
attribute="xtra"
permission="zope2.View"
/>

<browser:page
for="*"
name="morehome"
class=".homepage.moreView"
permission="zope2.View"
/>


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
Plone-Users mailing list
Plone...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plone-users

i00

unread,
Jan 1, 2010, 2:59:02 AM1/1/10
to plone...@lists.sourceforge.net
got the fix after banging the head for quite a long time :-),

just add the following lines into xtra(self) function in DynamicHome class (if the coding practice is not correct please correct)
                self.portal = self._BrowserView__getParent
                self.portal().unrestrictedTraverse('morehome')
                moreHtml = self.portal().unrestrictedTraverse('morehome').render()


class DynamicHome(PloneKSSView):
        @kssaction
        def xtra(self,count):
                print count
                alsoProvides(self,IViewView)
                ksscore = self.getCommandSet('core')
                zopecommands = self.getCommandSet('zope')
                selector = ksscore.getHtmlIdSelector("more-news-box")
                context = aq_inner(self.context)
                request = aq_inner(self.request)
                self.portal = self._BrowserView__getParent
                self.portal().unrestrictedTraverse('morehome')
                moreHtml = self.portal().unrestrictedTraverse('morehome').render()

                ksscore.replaceHTML(selector,moreHtml,withKssSetup='True')

Thanks,
~i00
Reply all
Reply to author
Forward
0 new messages