[Checkins] SVN: z3ext.layoutform/ initial import

Nikolay Kim fafhrd at datacom.kz
Fri Mar 21 04:49:53 EDT 2008


Log message for revision 84830:
  initial import

Changed:
  A   z3ext.layoutform/
  A   z3ext.layoutform/branches/
  A   z3ext.layoutform/tags/
  A   z3ext.layoutform/trunk/
  A   z3ext.layoutform/trunk/AUTHOR.txt
  A   z3ext.layoutform/trunk/CHANGES.txt
  A   z3ext.layoutform/trunk/LICENSE.txt
  A   z3ext.layoutform/trunk/setup.py
  A   z3ext.layoutform/trunk/src/
  A   z3ext.layoutform/trunk/src/z3ext/
  A   z3ext.layoutform/trunk/src/z3ext/__init__.py
  A   z3ext.layoutform/trunk/src/z3ext/layoutform/
  A   z3ext.layoutform/trunk/src/z3ext/layoutform/__init__.py
  A   z3ext.layoutform/trunk/src/z3ext/layoutform/add.py
  A   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/
  A   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/__init__.py
  A   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/buttons.py
  A   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/configure.zcml
  A   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/error.pt
  A   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/form.pt
  A   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formadd.pt
  A   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formedit.pt
  A   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/subform.pt
  A   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/textarea.py
  A   z3ext.layoutform/trunk/src/z3ext/layoutform/configure.zcml
  A   z3ext.layoutform/trunk/src/z3ext/layoutform/edit.py
  A   z3ext.layoutform/trunk/src/z3ext/layoutform/field.py
  A   z3ext.layoutform/trunk/src/z3ext/layoutform/form.py
  A   z3ext.layoutform/trunk/src/z3ext/layoutform/i18n.py
  A   z3ext.layoutform/trunk/src/z3ext/layoutform/interfaces.py

-=-

Property changes on: z3ext.layoutform/trunk
___________________________________________________________________
Name: svn:ignore
   + bin
develop-eggs
eggs
parts
coverage
.installed.cfg


Added: z3ext.layoutform/trunk/AUTHOR.txt
===================================================================
--- z3ext.layoutform/trunk/AUTHOR.txt	                        (rev 0)
+++ z3ext.layoutform/trunk/AUTHOR.txt	2008-03-21 08:49:53 UTC (rev 84830)
@@ -0,0 +1 @@
+Nikolay Kim (fafhrd91 <at> gmail <dot> com)

Added: z3ext.layoutform/trunk/CHANGES.txt
===================================================================
--- z3ext.layoutform/trunk/CHANGES.txt	                        (rev 0)
+++ z3ext.layoutform/trunk/CHANGES.txt	2008-03-21 08:49:53 UTC (rev 84830)
@@ -0,0 +1,17 @@
+=======
+CHANGES
+=======
+
+- Use z3c.autoinclude
+
+
+0.1.1 (2008-01-22)
+------------------
+
+- Fixed missing import in add.py
+
+
+0.1 (2008-01-19)
+----------------
+
+- Initial release

Added: z3ext.layoutform/trunk/LICENSE.txt
===================================================================
--- z3ext.layoutform/trunk/LICENSE.txt	                        (rev 0)
+++ z3ext.layoutform/trunk/LICENSE.txt	2008-03-21 08:49:53 UTC (rev 84830)
@@ -0,0 +1,54 @@
+Zope Public License (ZPL) Version 2.1
+-------------------------------------
+
+A copyright notice accompanies this license document that
+identifies the copyright holders.
+
+This license has been certified as open source. It has also
+been designated as GPL compatible by the Free Software
+Foundation (FSF).
+
+Redistribution and use in source and binary forms, with or
+without modification, are permitted provided that the
+following conditions are met:
+
+1. Redistributions in source code must retain the
+   accompanying copyright notice, this list of conditions,
+   and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the accompanying
+   copyright notice, this list of conditions, and the
+   following disclaimer in the documentation and/or other
+   materials provided with the distribution.
+
+3. Names of the copyright holders must not be used to
+   endorse or promote products derived from this software
+   without prior written permission from the copyright
+   holders.
+
+4. The right to distribute this software or to use it for
+   any purpose does not give you the right to use
+   Servicemarks (sm) or Trademarks (tm) of the copyright
+   holders. Use of them is covered by separate agreement
+   with the copyright holders.
+
+5. If any files are modified, you must cause the modified
+   files to carry prominent notices stating that you changed
+   the files and the date of any change.
+
+Disclaimer
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS''
+  AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
+  NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+  AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+  NO EVENT SHALL THE COPYRIGHT HOLDERS BE
+  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+  DAMAGE.

Added: z3ext.layoutform/trunk/setup.py
===================================================================
--- z3ext.layoutform/trunk/setup.py	                        (rev 0)
+++ z3ext.layoutform/trunk/setup.py	2008-03-21 08:49:53 UTC (rev 84830)
@@ -0,0 +1,71 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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.
+#
+##############################################################################
+"""Setup for z3ext.layoutform package
+
+$Id$
+"""
+import sys, os
+from setuptools import setup, find_packages
+
+def read(*rnames):
+    return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
+version='0.2'
+
+
+setup(name='z3ext.layoutform',
+      version=version,
+      description="UI Skin for z3c.form based on z3ext.layout",
+      long_description=(
+          'Detailed Documentation\n' +
+          '======================\n'
+          + '\n\n' +
+          read('CHANGES.txt')
+          ),
+      classifiers=[
+        'Development Status :: 5 - Production/Stable',
+        'Environment :: Web Environment',
+        'Intended Audience :: Developers',
+        'License :: OSI Approved :: Zope Public License',
+        'Programming Language :: Python',
+        'Natural Language :: English',
+        'Operating System :: OS Independent',
+        'Topic :: Internet :: WWW/HTTP',
+        'Framework :: Zope3'],
+      author='Nikolay Kim',
+      author_email='fafhrd91 at gmail.com',
+      url='http://z3ext.net/',
+      license='ZPL 2.1',
+      packages=find_packages('src'),
+      package_dir = {'':'src'},
+      namespace_packages=['z3ext'],
+      install_requires = ['setuptools',
+			  'zope.publisher',
+			  'zope.component',
+			  'zope.pagetemplate',
+			  'zope.app.pagetemplate',
+			  'zope.i18nmessageid',
+			  'zope.lifecycleevent',
+
+			  'z3c.form',
+                          'z3c.macro',
+                          'z3c.template',
+			  'z3c.autoinclude',
+
+                          'z3ext.layout',
+			  'z3ext.statusmessage',
+                          ],
+      include_package_data = True,
+      zip_safe = False
+      )


Property changes on: z3ext.layoutform/trunk/setup.py
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Id

Added: z3ext.layoutform/trunk/src/z3ext/__init__.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/__init__.py	                        (rev 0)
+++ z3ext.layoutform/trunk/src/z3ext/__init__.py	2008-03-21 08:49:53 UTC (rev 84830)
@@ -0,0 +1,6 @@
+# namespace package boilerplate
+try:
+    __import__('pkg_resources').declare_namespace(__name__)
+except ImportError, e:
+    from pkgutil import extend_path
+    __path__ = extend_path(__path__, __name__)


Property changes on: z3ext.layoutform/trunk/src/z3ext/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: z3ext.layoutform/trunk/src/z3ext/layoutform/__init__.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/__init__.py	                        (rev 0)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/__init__.py	2008-03-21 08:49:53 UTC (rev 84830)
@@ -0,0 +1,9 @@
+# This file is necessary to make this directory a package.
+
+from z3c.form import button
+
+from field import Fields
+from form import PageletForm
+from add import PageletAddForm
+from edit import PageletEditForm
+


Property changes on: z3ext.layoutform/trunk/src/z3ext/layoutform/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: z3ext.layoutform/trunk/src/z3ext/layoutform/add.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/add.py	                        (rev 0)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/add.py	2008-03-21 08:49:53 UTC (rev 84830)
@@ -0,0 +1,96 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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.
+#
+##############################################################################
+"""Support for Layout Templates
+
+$Id$
+"""
+from zope import interface, event
+from zope.lifecycleevent import ObjectCreatedEvent
+from zope.traversing.browser import absoluteURL
+from zope.app.container.interfaces import IAdding
+from zope.app.container.interfaces import IWriteContainer
+from zope.app.container.interfaces import IContainerNamesContainer
+
+from z3c.form import form, button
+from z3ext.layout.pagelet import BrowserPagelet
+from z3ext.statusmessage.interfaces import IStatusMessage
+
+import interfaces
+from i18n import _
+
+
+class PageletAddForm(form.AddForm, BrowserPagelet):
+    interface.implements(interfaces.IPageletAddForm)
+
+    render = BrowserPagelet.render
+    __call__ = BrowserPagelet.__call__
+
+    _addedObject = None
+
+    formCancelMessage = _(u'Action has been canceled.')
+
+    @button.buttonAndHandler(_(u'Add'), name='add',
+                             provides=interfaces.IAddButton)
+    def handleAdd(self, action):
+        data, errors = self.extractData()
+
+        if errors:
+            IStatusMessage(self.request).add(self.formErrorsMessage, 'warning')
+        else:
+            obj = self.createAndAdd(data)
+
+            if obj is not None:
+                self._addedObject = obj
+                self._finishedAdd = True
+                self.redirect(self.nextURL())
+
+    @button.buttonAndHandler(_(u'Cancel'), name='cancel',
+                             provides=interfaces.ICancelButton)
+    def handleCancel(self, action):
+        self._finishedAdd = True
+        self.redirect(self.cancelURL())
+        IStatusMessage(self.request).add(self.formCancelMessage)
+
+    def createAndAdd(self, data):
+        obj = self.create(data)
+        event.notify(ObjectCreatedEvent(obj))
+        self.add(obj)
+        return obj
+
+    def nextURL(self):
+        if self._addedObject is None:
+	    return '%s/@@SelectedManagementView.html'%\
+                absoluteURL(self.context, self.request)
+        else:
+            return absoluteURL(self._addedObject, self.request) + '/'
+
+    def cancelURL(self):
+        context = self.context
+
+        if IAdding.providedBy(context):
+            return '%s/'%absoluteURL(context.context, self.request)
+        else:
+            return '%s/'%absoluteURL(context, self.request)
+
+    def nameAllowed(self):
+        """Return whether names can be input by the user."""
+        context = self.context
+
+        if IAdding.providedBy(context):
+            context = context.context
+
+        if IWriteContainer.providedBy(context):
+            return not IContainerNamesContainer.providedBy(context)
+        else:
+            return False


Property changes on: z3ext.layoutform/trunk/src/z3ext/layoutform/add.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/__init__.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/__init__.py	                        (rev 0)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/__init__.py	2008-03-21 08:49:53 UTC (rev 84830)
@@ -0,0 +1 @@
+# This file is necessary to make this directory a package.


Property changes on: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/buttons.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/buttons.py	                        (rev 0)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/buttons.py	2008-03-21 08:49:53 UTC (rev 84830)
@@ -0,0 +1,52 @@
+##############################################################################
+#
+# Copyright (c) 2008 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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.
+#
+##############################################################################
+""" Castom Button Widget Implementation
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+from zope import interface, component
+
+from z3c.form import interfaces, widget, action, button
+
+from z3ext.layoutform.interfaces import \
+    IAddButton, ISaveButton, ICancelButton, ILayoutFormLayer
+
+
+class ButtonAction(button.ButtonAction):
+    interface.implements(interfaces.IButtonAction)
+    component.adapts(ILayoutFormLayer, interfaces.IButton)
+
+    klass="z-form-button"
+
+
+class AddButtonAction(button.ButtonAction):
+    interface.implements(interfaces.IButtonAction)
+    component.adapts(ILayoutFormLayer, IAddButton)
+
+    klass="z-form-addbutton"
+
+
+class SaveButtonAction(button.ButtonAction):
+    interface.implements(interfaces.IButtonAction)
+    component.adapts(ILayoutFormLayer, ISaveButton)
+
+    klass="z-form-savebutton"
+
+
+class CancelButtonAction(button.ButtonAction):
+    interface.implements(interfaces.IButtonAction)
+    component.adapts(ILayoutFormLayer, ICancelButton)
+
+    klass="z-form-cancelbutton"


Property changes on: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/buttons.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/configure.zcml
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/configure.zcml	                        (rev 0)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/configure.zcml	2008-03-21 08:49:53 UTC (rev 84830)
@@ -0,0 +1,103 @@
+<configure 
+   xmlns="http://namespaces.zope.org/zope"
+   xmlns:z3c="http://namespaces.zope.org/z3c">
+
+  <!-- buttons -->
+  <adapter 
+     provides="z3c.form.interfaces.IButtonAction"
+     factory=".buttons.ButtonAction" />
+
+  <adapter 
+     provides="z3c.form.interfaces.IButtonAction"
+     factory=".buttons.AddButtonAction" />
+
+  <adapter 
+     provides="z3c.form.interfaces.IButtonAction"
+     factory=".buttons.SaveButtonAction" />
+
+  <adapter 
+     provides="z3c.form.interfaces.IButtonAction"
+     factory=".buttons.CancelButtonAction" />
+
+  <!-- TextArea widget -->
+  <class class=".textarea.TextAreaWidget">
+    <require
+       permission="zope.Public"
+       interface="z3c.form.interfaces.ITextAreaWidget" />
+  </class>
+  
+  <adapter 
+     for="zope.schema.interfaces.IText
+          ..interfaces.ILayoutFormLayer"
+     factory=".textarea.TextAreaFieldWidget" />
+
+  <!-- templates -->
+  <z3c:template
+     template="form.pt"
+     for="..interfaces.IPageletForm"
+     layer="..interfaces.ILayoutFormLayer" />
+
+  <z3c:template
+     template="formadd.pt"
+     for="..interfaces.IPageletAddForm"
+     layer="..interfaces.ILayoutFormLayer" />
+
+  <z3c:template
+     template="formedit.pt"
+     for="..interfaces.IPageletEditForm"
+     layer="..interfaces.ILayoutFormLayer" />
+
+  <z3c:template
+     template="subform.pt"
+     for="z3c.form.interfaces.ISubForm"
+     layer="..interfaces.ILayoutFormLayer" />
+
+  <!-- Error View -->
+  <z3c:template
+     for="z3c.form.interfaces.IErrorViewSnippet"
+     template="error.pt"
+     layer="..interfaces.ILayoutFormLayer" />
+
+  <!-- form macros -->
+  <z3c:macro
+     view="..interfaces.IPageletForm"
+     name="form"
+     template="form.pt"
+     layer="..interfaces.ILayoutFormLayer" />
+
+  <z3c:macro
+     view="..interfaces.IPageletForm"
+     name="form-header"
+     macro="header"
+     template="form.pt"
+     layer="..interfaces.ILayoutFormLayer" />
+
+  <z3c:macro
+     view="..interfaces.IPageletForm"
+     name="widget-rows"
+     macro="widget-rows"
+     template="form.pt"
+     layer="..interfaces.ILayoutFormLayer" />
+
+  <z3c:macro
+     view="..interfaces.IPageletForm"
+     name="widget-row"
+     macro="widget-row"
+     template="form.pt"
+     layer="..interfaces.ILayoutFormLayer" />
+
+  <z3c:macro
+     view="..interfaces.IPageletForm"
+     name="form-buttons"
+     macro="buttons"
+     template="form.pt"
+     layer="..interfaces.ILayoutFormLayer" />
+
+  <z3c:macro
+     view="..interfaces.IPageletAddForm"
+     name="form-buttons"
+     macro="buttons"
+     template="formadd.pt"
+     layer="..interfaces.ILayoutFormLayer" />
+
+</configure>

Added: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/error.pt
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/error.pt	                        (rev 0)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/error.pt	2008-03-21 08:49:53 UTC (rev 84830)
@@ -0,0 +1 @@
+<div tal:content="view/message">Error</div>

Added: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/form.pt
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/form.pt	                        (rev 0)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/form.pt	2008-03-21 08:49:53 UTC (rev 84830)
@@ -0,0 +1,71 @@
+<div class="z-form z-form-standard">
+  <form action="." method="post" enctype="multipart/form-data" 
+	tal:attributes="method view/method;
+			enctype view/enctype;
+			acceptCharset view/acceptCharset;
+			accept view/accept;
+			action view/action;
+			name view/name;
+			id view/id"
+	metal:define-macro="form">
+
+    <div metal:define-slot="viewspace">
+      <metal:block define-macro="header">
+	<metal:block define-slot="header">
+	  <h1 i18n:translate=""
+	      tal:condition="view/label|nothing"
+	      tal:content="view/label|nothing"
+	      metal:define-slot="heading">Do something</h1>
+	  <div class="z-form-description" 
+	       tal:condition="view/description|nothing"
+	       tal:content="view/description|nothing"></div>
+	</metal:block>
+      </metal:block>
+
+      <div metal:define-slot="extra-info" tal:replace="nothing"></div>
+
+      <div metal:define-slot="main">
+	<div class="z-form-fieldset">
+	  <metal:block define-macro="widget-rows">
+	    <metal:block metal:define-slot="extra-top" />
+	    
+	    <tal:block tal:repeat="widget view/widgets/values">
+	      <div class="z-form-field" metal:define-macro="widget-row"
+		   tal:define="error widget/error|nothing"
+		   tal:attributes="class python:error and 'z-form-field error' or 'z-form-field'">
+		<label for="field.name" title="The widget's hint"
+		       tal:attributes="for widget/name;
+				       title widget/field/description"
+		       tal:content="widget/label">The Label</label>
+
+		<span class="z-form-fieldRequired" tal:condition="widget/required">&nbsp;</span>
+
+		<div tal:condition="error" tal:replace="structure error/render">
+		  The Error
+		</div>
+		<div class="z-form-help" tal:content="structure widget/field/description"></div>
+		<div tal:content="structure widget/render">
+		  <input type="text" style="width:100%"/>
+		</div>
+	      </div>
+	    </tal:block>
+	    <metal:block metal:define-slot="extra-bottom" />
+	  </metal:block>
+	</div>
+      </div>
+      <metal:block define-slot="above-buttons"></metal:block>
+    </div>
+
+    <metal:block define-slot="buttons">
+      <div class="z-form-controls" metal:define-macro="buttons">
+	<hr />
+	<span tal:condition="view/actions/values"
+	      metal:define-slot="bottom_buttons">
+	  <input tal:repeat="action view/actions/values"
+		 tal:replace="structure action/render" />
+	</span>
+	<metal:block define-slot="bottom-buttons"/>
+      </div>
+    </metal:block>
+  </form>
+</div>

Added: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formadd.pt
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formadd.pt	                        (rev 0)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formadd.pt	2008-03-21 08:49:53 UTC (rev 84830)
@@ -0,0 +1,25 @@
+<div class="z-form z-form-add" i18n:domain="z3ext">
+  <metal:block metal:use-macro="macro:form">
+    <metal:block metal:fill-slot="buttons">
+      <div class="z-form-controls" metal:define-macro="buttons">
+	<hr />
+	<div class="z-form-field" tal:condition="view/nameAllowed|nothing">
+	  <label i18n:translate="">Content short name</label>
+	  <div class="z-form-help" i18n:translate="">
+	    Should not contain spaces, underscores or mixed case. 
+	    Short Name is part of the item's web address.
+	  </div>
+	  <div>
+	    <input type="text" name="add_input_name"
+		   tal:attributes="value request/add_input_name | nothing" />
+	  </div>
+	</div>
+
+	<span tal:condition="view/actions/values">
+	  <input tal:repeat="action view/actions/values"
+		 tal:replace="structure action/render" />
+	</span>
+      </div>
+    </metal:block>
+  </metal:block>
+</div>

Added: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formedit.pt
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formedit.pt	                        (rev 0)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formedit.pt	2008-03-21 08:49:53 UTC (rev 84830)
@@ -0,0 +1,3 @@
+<div class="z-form z-form-edit">
+  <metal:block metal:use-macro="macro:form" />
+</div>

Added: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/subform.pt
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/subform.pt	                        (rev 0)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/subform.pt	2008-03-21 08:49:53 UTC (rev 84830)
@@ -0,0 +1,24 @@
+<div class="fieldset">
+  <h1 i18n:translate=""
+      tal:condition="view/label|nothing"
+      tal:content="view/label|nothing">Do something</h1>
+  <div class="formDescription" tal:content="view/description|nothing"></div>
+  
+  <metal:block define-macro="widget-rows">
+    <metal:block metal:define-slot="extra_top" />
+    
+    <tal:block tal:repeat="widget view/widgets/values">
+      <metal:block use-macro="context/@@form_macros/widget_row"/>
+    </tal:block>
+    
+    <metal:block metal:define-slot="extra-bottom" />
+  </metal:block>
+</div>
+
+<tal:block tal:condition="view/actions|nothing">
+  <hr />
+  <span class="buttons">
+    <input tal:repeat="action view/actions/values"
+	   tal:replace="structure action/render" />
+  </span>
+</tal:block>

Added: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/textarea.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/textarea.py	                        (rev 0)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/textarea.py	2008-03-21 08:49:53 UTC (rev 84830)
@@ -0,0 +1,52 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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.
+#
+##############################################################################
+"""Text Area Widget Implementation
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+from zope import interface, component, schema
+
+from z3c.form import interfaces
+from z3c.form.widget import Widget, FieldWidget
+from z3c.form.browser import widget, textarea
+
+from z3ext.layoutform.interfaces import ILayoutFormLayer
+
+
+class TextAreaWidget(textarea.TextAreaWidget):
+    """Textarea widget implementation."""
+
+    rows = 7
+
+
+ at component.adapter(schema.interfaces.IField, ILayoutFormLayer)
+ at interface.implementer(interfaces.IFieldWidget)
+def TextAreaFieldWidget(field, request):
+    """IFieldWidget factory for TextWidget."""
+    return FieldWidget(field, TextAreaWidget(request))
+
+
+
+class DescriptionWidget(textarea.TextAreaWidget):
+    """Textarea widget implementation."""
+
+    rows = 4
+
+
+ at component.adapter(schema.interfaces.IField, ILayoutFormLayer)
+ at interface.implementer(interfaces.IFieldWidget)
+def DescriptionFieldWidget(field, request):
+    """IFieldWidget factory for TextWidget."""
+    return FieldWidget(field, DescriptionWidget(request))


Property changes on: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/textarea.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: z3ext.layoutform/trunk/src/z3ext/layoutform/configure.zcml
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/configure.zcml	                        (rev 0)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/configure.zcml	2008-03-21 08:49:53 UTC (rev 84830)
@@ -0,0 +1,9 @@
+<configure 
+   xmlns="http://namespaces.zope.org/zope"
+   xmlns:z3c="http://namespaces.zope.org/z3c">
+
+  <autoinclude package="z3ext.layoutform" />
+
+  <include package=".browser" />
+
+</configure>

Added: z3ext.layoutform/trunk/src/z3ext/layoutform/edit.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/edit.py	                        (rev 0)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/edit.py	2008-03-21 08:49:53 UTC (rev 84830)
@@ -0,0 +1,66 @@
+##############################################################################
+#
+# Copyright (c) 2008 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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$
+"""
+from zope import interface, event
+from zope.traversing.browser import absoluteURL
+from zope.lifecycleevent import ObjectCreatedEvent
+from zope.app.container.interfaces import IAdding
+from zope.app.container.interfaces import IWriteContainer
+from zope.app.container.interfaces import IContainerNamesContainer
+
+from z3c.form import form, button
+from z3ext.layout.pagelet import BrowserPagelet
+from z3ext.statusmessage.interfaces import IStatusMessage
+
+import interfaces
+from i18n import _
+
+
+class PageletEditForm(form.EditForm, BrowserPagelet):
+    interface.implements(interfaces.IPageletEditForm)
+
+    render = BrowserPagelet.render
+    __call__ = BrowserPagelet.__call__
+
+    formCancelMessage = _(u'Edit action has been canceled.')
+
+    @button.buttonAndHandler(_(u'Save'), name='save',
+                             provides=interfaces.ISaveButton)
+    def handleApply(self, action):
+        data, errors = self.extractData()
+        if errors:
+            IStatusMessage(self.request).add(self.formErrorsMessage, 'warning')
+        else:
+            changes = self.applyChanges(data)
+            if changes:
+                IStatusMessage(self.request).add(self.successMessage)
+            else:
+                IStatusMessage(self.request).add(self.noChangesMessage)
+
+    @button.buttonAndHandler(_(u'Cancel'), name='cancel',
+                             provides=interfaces.ICancelButton)
+    def handleCancel(self, action):
+        self.redirect(self.cancelURL())
+        IStatusMessage(self.request).add(self.formCancelMessage)
+
+    def nextURL(self):
+        return '%s/@@SelectedManagementView.html'%\
+            absoluteURL(self.context, self.request)
+
+    def cancelURL(self):
+        return '%s/@@SelectedManagementView.html'%\
+            absoluteURL(self.context, self.request)


Property changes on: z3ext.layoutform/trunk/src/z3ext/layoutform/edit.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: z3ext.layoutform/trunk/src/z3ext/layoutform/field.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/field.py	                        (rev 0)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/field.py	2008-03-21 08:49:53 UTC (rev 84830)
@@ -0,0 +1,26 @@
+##############################################################################
+#
+# Copyright (c) 2008 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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$
+"""
+from z3c.form import field
+from zope.proxy import removeAllProxies
+
+
+class Fields(field.Fields):
+
+    def __init__(self, *args, **kw):
+        super(Fields, self).__init__(
+            *[removeAllProxies(arg) for arg in args], **kw)


Property changes on: z3ext.layoutform/trunk/src/z3ext/layoutform/field.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: z3ext.layoutform/trunk/src/z3ext/layoutform/form.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/form.py	                        (rev 0)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/form.py	2008-03-21 08:49:53 UTC (rev 84830)
@@ -0,0 +1,30 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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.
+#
+##############################################################################
+"""Support for Layout Templates
+
+$Id$
+"""
+from zope import interface
+
+from z3c.form import form
+from z3ext.layout.pagelet import BrowserPagelet
+
+from interfaces import IPageletForm
+
+
+class PageletForm(form.Form, BrowserPagelet):
+    interface.implements(IPageletForm)
+
+    render = BrowserPagelet.render
+    __call__ = BrowserPagelet.__call__


Property changes on: z3ext.layoutform/trunk/src/z3ext/layoutform/form.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: z3ext.layoutform/trunk/src/z3ext/layoutform/i18n.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/i18n.py	                        (rev 0)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/i18n.py	2008-03-21 08:49:53 UTC (rev 84830)
@@ -0,0 +1,19 @@
+##############################################################################
+#
+# Copyright (c) 2008 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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.
+#
+##############################################################################
+""" i18n
+
+$Id$
+"""
+from zope.i18nmessageid import MessageFactory
+_ = MessageFactory('z3ext')


Property changes on: z3ext.layoutform/trunk/src/z3ext/layoutform/i18n.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: z3ext.layoutform/trunk/src/z3ext/layoutform/interfaces.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/interfaces.py	                        (rev 0)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/interfaces.py	2008-03-21 08:49:53 UTC (rev 84830)
@@ -0,0 +1,71 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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.
+#
+##############################################################################
+""" z3ext.layout interfaces
+
+$Id$
+"""
+from zope import interface
+from z3c.form.interfaces import IFormLayer
+from z3ext.layout.interfaces import IPagelet
+
+
+class ILayoutFormLayer(IFormLayer):
+    """ browser layer """
+
+
+class IPageletForm(IPagelet):
+    """Form mixin for pagelet implementation."""
+
+    label = interface.Attribute('Form label')
+
+    description = interface.Attribute('Form label')
+
+
+class IPageletAddForm(IPageletForm):
+    """Add form mixin for pagelet implementation."""
+
+    formCancelMessage = interface.Attribute('Form cancel message')
+
+    def nextURL():
+        """ as next url use newly created content url """
+
+    def cancelURL():
+        """ cancel url """
+
+    def nameAllowed():
+        """Return whether names can be input by the user."""
+
+
+class IPageletEditForm(IPageletForm):
+    """Edit form mixin for pagelet implementation."""
+
+    formCancelMessage = interface.Attribute('Form cancel message')
+
+    def nextURL():
+        """ as next url use newly created content url """
+
+    def cancelURL():
+        """ cancel url """
+
+
+class IAddButton(interface.Interface):
+    """ add button """
+
+
+class ISaveButton(interface.Interface):
+    """ save button """
+
+
+class ICancelButton(interface.Interface):
+    """ cancel button """


Property changes on: z3ext.layoutform/trunk/src/z3ext/layoutform/interfaces.py
___________________________________________________________________
Name: svn:keywords
   + Id



More information about the Checkins mailing list