I agree and think that this is what we are talking about. I like the _spirit_ of interfaces, not necessarily the zope implementation code. I would rather see a default or 'gold' component that is downloadable and usable, and other alternate implementations.

So if a developer downloaded and is usuing your menu code below I could write a better one that uses <UL>and <LI> rather then divs and people could drop in my class as a replacement for yours.

Someone else could then provide another class that uses a menu class and prints out breadcrumbs...

and so on...

-Aaron


Jim Bucher wrote:


I like the idea of using components for reusability. But interfaces, inheritance and mixins seem to be a complex solution. How about doing it this way. Make the component a class that stands on its own. When the component needs to interact with a page, session, etc then give it access to those objects. It seems to be simple. What do you think? Here is a quick example.


##### Menu.py


class Menu:

items = [] # a list of ('URL name', 'menu name') tuples

  def write(self, page):
    page.writeln("<div class='menu'>")
    for item in self.items:
      page.writeln("<a href='%s'> %s </a> &nbsp" % item)
    page.writeln("</div>")

  def add(self, item):
    self.items.append(item)

  def remove(self, index):
    self.items.pop(index)


##### SitePage.py


from WebKit.Page import Page
from Menu import Menu

class SitePage(Page):

  def __init__(self):
    Page.__init__(self)
    self.createMenu()

  def createMenu(self):
    self.menu = Menu()
    menu = self.menu
    menu.add('Login','Login')
    menu.add('Project','Select Project')
    menu.add('Soil', 'Soils')
    menu.add('Plant', 'Plants')
    menu.add('PlantCommunity', 'Plant Communities')
    menu.add('Grazer', 'Grazers / Preferences')
    menu.add('GrazerPlan', 'Grazing Profiles')
    menu.add('Run', 'Model Runs')

  def writeBodyParts(self):
    self.menu.write(self)



-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger for complex code. Debugging C/C++ programs can leave you feeling lost and disoriented. TotalView can help you find your way. Available on major UNIX and Linux platforms. Try it free. www.etnus.com
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss





-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger for complex code. Debugging C/C++ programs can leave you feeling lost and disoriented. TotalView can help you find your way. Available on major UNIX and Linux platforms. Try it free. www.etnus.com
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to