[Zope3-checkins] CVS: zopeproducts/hellopackage - README.txt:1.1 __init__.py:1.1 configure.zcml:1.1 configure_bare.zcml:1.1 hello.pt:1.1 hellomodule.py:1.1 interfaces.py:1.1

Viktorija Zaksiene ryzaja@codeworks.lt
Wed, 5 Feb 2003 05:52:20 -0500


Update of /cvs-repository/zopeproducts/hellopackage
In directory cvs.zope.org:/tmp/cvs-serv9438/hellopackage

Added Files:
	README.txt __init__.py configure.zcml configure_bare.zcml 
	hello.pt hellomodule.py interfaces.py 
Log Message:
Renamed HelloPackage to fit grand renaming rules.


=== Added File zopeproducts/hellopackage/README.txt ===
A Zope 3 "Hello World" example. We create a content object that has
a method called 'getHello' that will return Hello world. We make
a very basic view for this content object. Finally we make the object
addable.

In this package we are excessively explicit in the naming in an attempt to
make it more clear what's going on, especially in the ZCML. Instead of naming
everything left and right 'Hello', there is now a distinction in the package
name, module name, etc. This is not the normal style of naming in Zope 3
however.

'configure.zcml' contains a lot of comments.

To enable this, go to your 'products.zcml' in the Zope 3 root and 
add the line:

<include package="zopeproducts.hellopackage" />

presuming you installed this package in ZopeProducts.



=== Added File zopeproducts/hellopackage/__init__.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
# 
##############################################################################
"""

$Id: __init__.py,v 1.1 2003/02/05 10:52:16 ryzaja Exp $
"""


=== Added File zopeproducts/hellopackage/configure.zcml ===
<!-- An extensively commented configure.zcml. If you want to see
     the same file without any comments, check out 'configure_bare.zcml
-->

<!--
zopeConfigure is the root element of the ZCML file.

Besides enclosing the rest of the directive, you define some
namespaces on it in the standard XML namespaces way.

xmlns="uri" defines the default namespace elements are in (when they don't
use the 'foo:bar' notation).

xmlns:foo="uri" defines another namespace. You can put elements in that
namespace by using the defined prefix ('foo:bar').
-->
<zopeConfigure
   xmlns="http://namespaces.zope.org/zope"
   xmlns:browser="http://namespaces.zope.org/browser">

<!--
Declaration of a content object.

This is defined by HelloClass in hellomodule.
-->
<content class=".hellomodule.HelloClass">

  <!--
  More information about making new Hello objects.

  id is used later to refer to it in the add menu. Permission is
  used to restrict who is allowed to add Hello objects.
  -->
  <factory
      id="Hello"
      permission="zope.ManageContent"
      title="Hello world"
      description="A simple hello world object." />

  <!--
  Permissions on using Hello objects.

  We specify which permission is needed to use attributes. We can have
  more of these, and attributes can be a list as well ('foo bar baz')
  -->
  <require
      permission="zope.View"
      attributes="getHello" />
</content>

<!--
Create a hello.html view for Hello object.

The view has a name (hello.html), it applies to an interface
(interfaces.IHello). The view is made from a page template called
hello.pt. Only people with the 'Zope.View' permission may use this
view.
-->
<browser:page
    name="hello.html"
    for=".interfaces.IHello"
    template="hello.pt"
    permission="zope.View" />

<!--
'hello.html' is the default view for the Hello object.
-->
<browser:defaultView
    name="hello.html"
    for=".interfaces.IHello" />

<!--
Add the Hello object to the add menu.

The add menu is called 'add_content'. It's always a special kind of
view on the Zope.App.OFS.Container.IAdding interface.

'action' refers to the id of the content object to add.

'title' is what will show up in the add menu as the name of the
object. 'description' will show up as a description in the add menu as
well.
-->
<browser:menuItem
    menu="add_content"
    for="zope.app.interfaces.container.IAdding."
    action="Hello"
    title="Hello world"
    description="An object for hello worlding." />

</zopeConfigure>


=== Added File zopeproducts/hellopackage/configure_bare.zcml ===
<!-- See configure.zcml for this with a lot of comments. This is just
     to demo how short it is without comments. -->
<zopeConfigure
   xmlns="http://namespaces.zope.org/zope"
   xmlns:browser="http://namespaces.zope.org/browser">

<content class=".hellomodule.HelloClass">
  <factory
      id="Hello"
      permission="zope.ManageContent"
      title="Hello world"
      description="A simple hello world object." />
  <require
      permission="zope.View"
      attributes="getHello" />
</content>

<browser:page
    name="hello.html"
    for=".interfaces.IHello"
    template="hello.pt"
    permission="zope.View" />

<browser:defaultView
    name="hello.html"
    for=".interfaces.IHello" />

<browser:menuItem
    menu="add_content"
    for="zope.app.interfaces.container.IAdding."
    action="Hello"
    title="Hello world"
    description="An object for hello worlding." />

</zopeConfigure>


=== Added File zopeproducts/hellopackage/hello.pt ===
<html>
<body>
<p tal:content="context/getHello">Replace this</p>
</body>
</html>

=== Added File zopeproducts/hellopackage/hellomodule.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
# 
##############################################################################
"""
$Id: hellomodule.py,v 1.1 2003/02/05 10:52:16 ryzaja Exp $
"""
from interfaces import IHello
from persistence import Persistent

class HelloClass(Persistent):
    __implements__ = IHello

    def getHello(self):
        return "Hello world"


=== Added File zopeproducts/hellopackage/interfaces.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
# 
##############################################################################
"""
$Id: interfaces.py,v 1.1 2003/02/05 10:52:16 ryzaja Exp $
"""

from zope.interface import Interface

class IHello(Interface):
    """Hello
    """
    def getHello():
        """Return hello"""