[Zope3-checkins] CVS: Products3/NewsSite - addform.pt:1.1 editform.pt:1.1 configure.zcml:1.21 newssite.py:1.8
Tres Seaver
tseaver@zope.com
Thu, 27 Mar 2003 12:43:13 -0500
Update of /cvs-repository/Products3/NewsSite
In directory cvs.zope.org:/tmp/cvs-serv16659
Modified Files:
configure.zcml newssite.py
Added Files:
addform.pt editform.pt
Log Message:
- Add some preliminary skeleton for login exercises (need to look at
how Zope2 / CMF do this for Basic Auth, as this is borked!)
- Make add and edit forms use custom templates, which honor the
look-and-feel we want to use for the news site. This is still
problematic:
o We had to copy templates from zope/app/browser/forms and modify.
o We couldn't re-skin all the templates (e.g, the workflow template).
XXX Need to talk with Jim et. aliae about the "intended" pattern for
this.
=== Added File Products3/NewsSite/addform.pt ===
<html metal:use-macro="views/newssite_macros/page">
<head>
<title>Add News</title>
</head>
<body>
<div metal:fill-slot="body">
<div metal:define-macro="body">
<form action="." tal:attributes="action request/URL" method="POST"
enctype="multipart/form-data"
>
<div metal:define-macro="formbody">
<h3 tal:condition="view/label"
tal:content="view/label"
metal:define-slot="heading"
>Edit something</h3>
<p tal:define="status view/update"
tal:condition="status"
tal:content="status" />
<div tal:condition="view/errors">
<ul>
<li tal:repeat="error view/errors">
<strong tal:content="error/__class__">
Error Type</strong>:
<span tal:content="error">Error text</span>
</li>
</ul>
</div>
<div metal:define-slot="extra_info" tal:replace="nothing">
</div>
<div class="row" metal:define-slot="extra_top" tal:replace="nothing">
<div class="label">Extra top</div>
<div class="label"><input type="text" style="width:100%" /></div>
</div>
<div class="row"
metal:define-macro="widget_rows" tal:repeat="widget view/widgets"
tal:content="structure widget/row">
<div class="label">Name</div>
<div class="field"><input type="text" style="width:100%" /></div>
</div>
<div class="row"
metal:define-slot="extra_bottom" tal:replace="nothing">
<div class="label">Extra bottom</div>
<div class="field"><input type="text" style="width:100%" /></div>
</div>
</div>
<div class="row">
<div class="controls">
<input type="submit" value="Refresh" />
<input type="submit" name="UPDATE_SUBMIT" value="Submit" />
</div>
</div>
</form>
</div>
</div>
</body>
</html>
=== Added File Products3/NewsSite/editform.pt ===
<tal:tag condition="view/update"
/><html metal:use-macro="views/newssite_macros/page">
<body>
<div metal:fill-slot="body">
<div metal:define-macro="body">
<form action="." tal:attributes="action request/URL" method="POST"
enctype="multipart/form-data"
>
<div metal:define-macro="formbody">
<h3 tal:condition="view/label"
tal:content="view/label"
metal:define-slot="heading"
>Edit something</h3>
<p tal:define="status view/update"
tal:condition="status"
tal:content="status" />
<div tal:condition="view/errors">
<ul>
<li tal:repeat="error view/errors">
<strong tal:content="error/__class__">
Error Type</strong>:
<span tal:content="error">Error text</span>
</li>
</ul>
</div>
<div metal:define-slot="extra_info" tal:replace="nothing">
</div>
<div class="row"
metal:define-slot="extra_top" tal:replace="nothing">
<div class="label">Extra top</div>
<div class="field"><input type="text" style="width:100%" /></div>
</div>
<div class="row"
metal:define-macro="widget_rows" tal:repeat="widget view/widgets"
tal:content="structure widget/row">
<div class="label">Name</div>
<div class="field"><input type="text" style="width:100%" /></div>
</div>
<div class="row"
metal:define-slot="extra_bottom" tal:replace="nothing">
<div class="label">Extra bottom</div>
<div class="field"><input type="text" style="width:100%" /></div>
</div>
</div>
<div class="row">
<div class="controls">
<input type="submit" value="Refresh" />
<input type="submit" name="UPDATE_SUBMIT" value="Submit" />
</div>
</div>
</form>
</div>
</div>
</body>
</html>
=== Products3/NewsSite/configure.zcml 1.20 => 1.21 ===
--- Products3/NewsSite/configure.zcml:1.20 Thu Mar 27 11:41:08 2003
+++ Products3/NewsSite/configure.zcml Thu Mar 27 12:42:42 2003
@@ -263,6 +263,28 @@
menu="zmi_views"
title="Publisher review worklist"
/>
+
+<!--
+<browser:page
+ name="login.html"
+ for=".interfaces.INewsSite"
+ class=".newssite.NewsSiteView"
+ attribute="unauth"
+ permission="zope.View"
+ menu="newssite_actions"
+ title="Login"
+ />
+
+<browser:page
+ name="add_news.html"
+ for=".interfaces.INewsSite"
+ class=".newssite.NewsSiteView"
+ attribute="addNewsForm"
+ permission="zope.View"
+ menu="newssite_actions"
+ title="Add News"
+ />
+ -->
<!-- Render RSS for our items.
-->
@@ -290,6 +312,7 @@
name="syndication.html"
for=".interfaces.INewsSite"
class=".browser.NewsSiteSyndicationPoliciesView"
+ template="editform.pt"
schema=".interfaces.ISyndicationPolicies"
label="Syndication Policies"
permission="zopeproducts.NewsSite.ManageSyndication"
@@ -303,6 +326,7 @@
name="register.html"
for=".interfaces.INewsSite"
class=".register.MemberAddView"
+ template="addform.pt"
schema=".interfaces.IMember"
label="Registration"
arguments="login password"
@@ -329,6 +353,7 @@
name="memberdata.html"
for="zope.app.interfaces.security.IPrincipal"
schema=".interfaces.IMember"
+ template="editform.pt"
label="Member Data"
permission="zope.ManageContent"
menu="zmi_views"
=== Products3/NewsSite/newssite.py 1.7 => 1.8 ===
--- Products3/NewsSite/newssite.py:1.7 Thu Mar 27 11:04:57 2003
+++ Products3/NewsSite/newssite.py Thu Mar 27 12:42:42 2003
@@ -18,10 +18,15 @@
from zope.app.datetimeutils import parseDatetimetz
from persistence.dict import PersistentDict
+from zope.component import getService
+from zope.component import getAdapter, getView
+from zope.security.management import getSecurityManager
+from zope.exceptions.unauthorized import Unauthorized
from zope.publisher.browser import BrowserView
from zope.app.interfaces.annotation import IAnnotations
from zope.app.interfaces.dublincore import ICMFDublinCore
-from zope.component import getAdapter, getView
+from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
+from zope.app.services.servicenames import Authentication
from zope.app.content.folder import Folder
from zope.app.interfaces.workflow import IProcessInstanceContainerAdaptable
from zope.app.browser.workflow.stateful.interfaces import IContentFilterAdapter
@@ -50,6 +55,17 @@
def listPrivateNewsItems(self):
return self._list(state=u"private")
+
+ def unauth(self):
+ authsvc = getService(self.context, Authentication)
+ principal = getSecurityManager().getPrincipal()
+ if principal.getRoles():
+ self.request.response.redirect( getView( self.context
+ , 'absolute_url'
+ , self.request
+ ) )
+ else:
+ authsvc.unauthorized(None, self.request)
def _list(self, state=u"published"):
"""Return a sequence of mappings for our news items.