-1

I created browserView class named as "bdrMenuView" . It should be like "class bdrMenuView(BrowserView):" . and the class contains the method named as "createPictMenu" . The whole class should be

    class bdrMenuView(BrowserView):
              def createPictMenu(self):

Now i have written one more class named as LogoViewlet . It should be like "class LogoViewlet(ViewletBase):" . and the class contains the method named as "update" . The whole class should be

    class LogoViewlet(ViewletBase):
              def update(self):

Now i want to call the method of browserView class from another class. I created an instance of one class like

    class LogoViewlet(ViewletBase):
              def update(self):
                   a = bdrMenuView(self,BrowserView)      ---------> instance of BrowserView class
                   logoName = a.createPictMenu() 

I want to know whether it is correct or not which i created.

Python Team
  • 1,143
  • 4
  • 21
  • 50
  • I've seen on mailing lists that you are attempting to create a view out of the logo viewlet. That's a mistake. To make a menu you should use one of the existing menu portlets, or make your own based on them. – Lennart Regebro Jul 30 '13 at 06:53
  • I want to replace default plone logo to our menus.For that i used default LogoViewlet. in that i called my own class method. so it will be return our menus.... So that only i have to call our own class method from default LogoViewlet class... – Python Team Jul 30 '13 at 07:14
  • Oh, you want to change where the href link point? Is that what you are trying to say when you say that you want to "replace the logo to our menus"? – Lennart Regebro Jul 30 '13 at 07:16
  • yes i want to replace the logo to our menus.... – Python Team Jul 30 '13 at 07:18
  • I'm sorry, "replace the logo to our menus" makes no sense. I tried to guess what you meant, but I seem to have guessed wrong. You have to explain what you actually want to do. – Lennart Regebro Jul 30 '13 at 07:21
  • self.context.restrictedTraverse('@@bdrmenu') can u plz tell me what is exactly doing the above statement.... what i want to do is have to replace the default logo. i have a method named as createPictMenu. the method should be return the menus.... so i have to call this method to this class "class LogoViewlet(ViewletBase):"... – Python Team Jul 30 '13 at 08:15
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/34429/discussion-between-lennart-regebro-and-oomsys-python-team) – Lennart Regebro Jul 30 '13 at 08:25
  • Here I posted the question you *should* have posted: http://stackoverflow.com/questions/17941666/how-do-i-link-the-logo-to-an-external-site When you ask a question, explain what you are trying to achieve. – Lennart Regebro Jul 30 '13 at 08:26

1 Answers1

0

No, that is not correct and makes absolutely no sense. Why do you pass in the baseclass as a parameter? Please learn basic Python.

The parameters to views are the context and the request. The best way to make a view from inside another view (which a viewlet is) is to traverse to it. You can do this with restrictedTraverse.

The exact code depends on what your view is registered for. For example, if the view you want to look up is called @@bdrmenu and registered for any content, you would look it up with self.context.restrictedTraverse('@@bdrmenu').

Lennart Regebro
  • 167,292
  • 41
  • 224
  • 251