[Zope3-checkins] CVS: Products3/NewsSite/NewsItem - __init__.py:1.1 add.pt:1.1 browser.py:1.1 configure.zcml:1.1 edit.pt:1.1 info.pt:1.1 interfaces.py:1.1 news.py:1.1 newsitem_icon.gif:1.1

Grégoire Weber zope@i-con.ch
Tue, 25 Mar 2003 07:52:51 -0500


Update of /cvs-repository/Products3/NewsSite/NewsItem
In directory cvs.zope.org:/tmp/cvs-serv1570

Added Files:
	__init__.py add.pt browser.py configure.zcml edit.pt info.pt 
	interfaces.py news.py newsitem_icon.gif 
Log Message:
initial checkin of NewsItem, will be changed using Schemas


=== Added File Products3/NewsSite/NewsItem/__init__.py ===



=== Added File Products3/NewsSite/NewsItem/add.pt ===
<html metal:use-macro="views/standard_macros/page">
<head><title>Edit News Item</title></head>
<body>
<div metal:fill-slot="body">
Enter your Newsmessage
<form action="action.html" method="post">
<table cellspacing="0" cellpadding="2" border="0">
  <tr><td> Newsmessage</td>
      <td><input type="text" name="newsbody" size="40" value="" /> </td>
  </tr>
</table>
<input type="submit" name="submit" value=" Save Changes " />
</form></div></body></html>


=== Added File Products3/NewsSite/NewsItem/browser.py ===
from zope.component import getAdapter
from zope.app.event import publish
from zope.app.event.objectevent import ObjectModifiedEvent
from zope.app.interfaces.container import IAdding
from interfaces import INewsItemInfo, INewsItem, INewsItemAdd

class NewsItemInfoView:
    """Provide an interface for viewing a news item
    """

    __used_for__ = INewsItemInfo

    def __init__(self, context, request):
        self.context = context
        self.request = request
        

class NewsItemEditView:
    """Provide a user interface for editing a news item
    """
    
    # Assert that we can only be applied to INewsItem
    __used_for__ = INewsItem

    # action method
    def action(self, newsbody):
        "Edit a news item"
        self.context.update(newsbody)
        publish(self.context, ObjectModifiedEvent(self.context))
        self.request.response.redirect('.')

class NewsItemAddView:
    """Provide a user interface for adding a news item
    """
    
    # Assert that we can only be applied to IAdding
    __used_for__ = IAdding

    # action method
    def action(self, newsbody):
        "Add a news item"
        getAdapter(self.context, INewsItemAdd).add(newsbody)
        self.request.response.redirect(self.context.nextURL())


=== Added File Products3/NewsSite/NewsItem/configure.zcml ===
<zopeConfigure 
    xmlns='http://namespaces.zope.org/zope'
    xmlns:browser='http://namespaces.zope.org/browser'>

<permission
    id="zopeproducts.NewsSite.NewsItem.ManageNewsItems" 
    title="Manage News Items" />

<content class=".news.NewsItem">
  <implements
     interface="zope.app.interfaces.annotation.IAttributeAnnotatable" 
     />
  <factory
      id="zopeproducts.NewsItem"
      permission="zopeproducts.NewsSite.NewsItem.ManageNewsItems" />
  <require
      permission="zope.View"
      interface=".interfaces.INewsItemInfo" />
  <require
      permission="zopeproducts.NewsSite.NewsItem.ManageNewsItems"
      attributes="update" />
</content>

<adapter
    provides=".interfaces.INewsItemAdd"
    for="zope.app.interfaces.container.IAdding"
    factory=".news.NewsItemAdd"
    />

<browser:addview
    name="AddNewsItem"
    menu="add_content" title="News Item"
    class=".browser.NewsItemAddView"
    permission="zopeproducts.NewsSite.NewsItem.ManageNewsItems" 
    >

  <browser:page name="add.html" template="add.pt" />
  <browser:page name="action.html" attribute="action" />
</browser:addview>

<browser:defaultView for=".interfaces.INewsItemInfo" name="info.html" />

<browser:page
    for=".interfaces.INewsItemInfo"
    name="info.html" 
    template="info.pt"
    menu="zmi_views" title="View"
    class=".browser.NewsItemInfoView"
    permission="zope.View" 
    />

<browser:pages
    for=".interfaces.INewsItem"
    class=".browser.NewsItemEditView"
    permission="zopeproducts.NewsSite.NewsItem.ManageNewsItems" 
    >

  <browser:page 
      name="edit.html"       
      template="edit.pt"
      menu="zmi_views" title="Edit"
      />
  <browser:page name="editAction.html" attribute="action" />
</browser:pages>

<browser:icon name="zmi_icon" for=".interfaces.INewsItem" file="newsitem_icon.gif" />

</zopeConfigure>


=== Added File Products3/NewsSite/NewsItem/edit.pt ===
<html metal:use-macro="views/standard_macros/page">
<head><title>Edit News Item</title></head>
<body>
<div metal:fill-slot="body">
Enter yor News Message.
<form action="editAction.html" method="post">
<table cellspacing="0" cellpadding="2" border="0">
  <tr><td>News Message</td>
      <td><input type="text" name="first" size="40" value=""
           tal:attributes="value context/newsbody" /> </td>
  </tr>
</table>
<input type="submit" name="submit" value=" Save Changes " />
</form></div></body></html>


=== Added File Products3/NewsSite/NewsItem/info.pt ===
<html metal:use-macro="views/standard_macros/page">
<head><title>News Item XXX dublin core title here</title></head>
<body>
<div metal:fill-slot="body">
  <table border="0">
  <caption>News Message</caption>
  <tbody>
    <tr><td>News Message:</td>
        <td tal:content="context/newsbody">News Message</td>
    </tr>
  </tbody>
  </table>
</div></body></html>


=== Added File Products3/NewsSite/NewsItem/interfaces.py ===
from zope.interface import Interface

class INewsItemInfo(Interface):
    "Provides access to basic news information."

    def newsbody():
        """Get the newsbody
        """

class INewsItem(INewsItemInfo):
    "Provides the ability to change news information."

    def update(newsbody) :
        """Modifies news data
        
        'None' values are ignored.
        """

class INewsItemAdd(Interface):
    """Add context using IAdding objects
    """

    def add(newsbody):
        """Add a news initialized from the given arguments
        """



=== Added File Products3/NewsSite/NewsItem/news.py ===
import persistence
from interfaces import INewsItem, INewsItemInfo, INewsItemAdd
from zope.app.interfaces.container import IAdding
from zope.app.event import publish
from zope.app.event.objectevent import ObjectCreatedEvent

class NewsItem(persistence.Persistent):
    """News Item.
    """

    __implements__ = INewsItem

    def __init__(self, newsbody=''):
        self.update(newsbody)

    def newsbody(self):
        return self._newsbody

    def update(self, newsbody=None):
        if newsbody is not None:
            self._newsbody = newsbody
        
class NewsItemAdd:
    "Provide a user interface for adding a news item"
    
    # Assert that we can only be applied to IAdding
    __used_for__ = IAdding

    __implements__ = INewsItemAdd

    def __init__(self, context):
        self.context = context

    def add(self, newsbody):
        news_item = NewsItem()
        publish(self.context.context, ObjectCreatedEvent(news_item))
        news_item.update(newsbody)
        self.context.add(news_item)


=== Added File Products3/NewsSite/NewsItem/newsitem_icon.gif ===
  <Binary-ish file>