Difference between pages "Zope HOWTO" and "Spamtest"

(Difference between pages)
(example-configure.zcml)
 
 
Line 1: Line 1:
This page documents how to use Zope with Funtoo Experimental, which currently has good Zope support thanks to [[Progress Overlay Python]] integration.
+
{{#ask:
 +
[[Category:People]] [[Geoloc::+]] | limit=999 | format=count
 +
}}
  
== About Zope ==
 
  
Zope is an Open Source application server framework written in Python. It has an interesting history which you should familiarize yourself with before starting Zope development, as it contains several interesting twists and turns.
+
{{#ask:
 +
[[Category:People]] [[Geoloc::+]] | limit=999 | format=json
 +
}}
  
=== Zope History ===
+
{{#ask:
 +
[[Category:People]] [[Role type::+]] | limit=99999 | format=json
 +
}}
  
{{Note}} This HOWTO targets Zope 2.13, which includes Five. It is typically the version you should be using for new Zope projects.
 
  
* There are two versions of Zope, Zope 2 and Zope 3. One might assume that Zope 3 is the version that people should use for new software development projects by default, but this is not the case. Most Zope-based projects continue to use Zope 2. Zope 3 was an attempt to redesign Zope 2 from scratch, and is completely different from Zope 2, but it was not adopted by the community.
+
{{#ask:
 +
[[Category:People]] [[Geoloc::+]] | limit=999 | format=category
 +
}}
  
* There is also something called [http://codespeak.net/z3/five/ Five] (named because it is "2 + 3") that backports many of the new features of Zope 3 into the Zope 2 framework. Several projects will use Zope 2 plus Five in order to use some of the newer features in Zope. Five was merged into mainline Zope 2 in early 2010, and first appeared in Zope 2.8.
 
  
* You can learn more about the history of Zope 2, 3 and Five in the [http://svn.zope.org/Zope/trunk/src/Products/Five/README.txt?view=markup Five README].
+
{{#get_web_data:url=http://ports.funtoo.org/my.json|format=json|data=fcx8664=fcx8664}}
 +
== Funtoo / Gentoo Comparison (funtoo-current, x86-64bit) ==
 +
 +
{{#arraymaptemplate:{{#external_value:fcx8664}}|PkgCompareDisplay|,||}}
  
* To make things even more interesting, work on [http://docs.zope.org/zope2/releases/4.0/ Zope 4] is underway, and it will be based on 2.13 rather than 3.x. It includes a number of [http://docs.zope.org/zope2/releases/4.0/CHANGES.html#restructuring incompatible changes] with prior versions.
+
== Widgets ==
=== Zope Resources ===
+
{{#widget:MonthlyDonate}}
 +
{{#widget:Donate|blurb=Your support helps Funtoo grow! Donate via PayPal Today.}}
 +
{{#widget:DonateBitcoin|blurb=Use Bitcoin to support Funtoo.}}
 +
{{Litecoin|blurb=Check it out: Mine litecoins for Funtoo!}}{{#widget:DonateBitcoin|blurb=Your support helps Funtoo grow! Donate Today.}}
  
Now that you understand what version of Zope you should be targeting (2.13), we can point you towards the correct documentation :)
+
{{
 +
#ask:
 +
[[Category:People]]
 +
| ?geoloc
 +
| limit=99999
 +
}}
  
; '''[http://docs.zope.org/zope2/zope2book/ The Zope 2 Book]'''
+
{{#ask: [[Overlay::funtoo-overlay]]
: This book provides a general introduction to Zope concepts and ZMI. It is a good place to start, but doesn't provide a direct introduction to Zope development. It's recommended that you skim through this book to familiarize yourself with Zope. It generally does not assume much prior knowledge about Web development or Python.
+
| ? Ebuild
; '''[http://docs.zope.org/zope2/zdgbook/ Zope Developer's Guide]'''
+
| ? Maintained by
: This guide will give you a better introduction to Zope development. It assumes you already know Python. Skip chapters 1 and 2 and start in [http://docs.zope.org/zope2/zdgbook/ComponentsAndInterfaces.html chapter 3], which covers components and interfaces. [http://docs.zope.org/zope2/zdgbook/Products.html Chapter 5] covers the creation of your first product.
+
| ? Overlay
; '''[http://codespeak.net/z3/five/manual.html The Five Manual]'''
+
}}
: We're not done yet. There is a bunch of stuff in Zope 2.13 that is not in the official documentation. Namely, the stuff in Five.
+
   
; '''[http://docs.zope.org/ztkpackages.html ZTK Documentation]'''
+
{{#ask: [[Ebuild::+]]
: ZTK  
+
| ? Ebuild
; '''ZCA'''
+
| ? Maintained by
: [http://www.muthukadan.net/docs/zca.html A Comprehensive Guide to Zope Component Architecture] offers a good introduction to the programming concepts of ZCA. We also have a new page on [[Zope Component Architecture]] which will help you to understand the big picture of ZCA and why it is useful. ZCML ("Z-camel") is a part of ZCA and  was introduced in Zope 3, so typically you will find ZCML documented within Zope 3 documentation and book.
+
| ? Overlay
; '''Content Components'''
+
}}
: Views and Viewlets: [http://docs.zope.org/zope.viewlet/index.html This tutorial on viewlets] also contains some viewlet-related ZCML examples near the end. The "Content Component way" of developing in Zope seems to be a Zope 3 thing and tied to ZCML. Chapter 13+ of Stephan Richter's ''Zope 3 Developer's Handbook'' (book) seems to cover this quite well. You will probably also want to check out Philipp Weitershausen's ''Web Component Development with Zope 3'' (book).
+
; '''[http://wiki.zope.org/zope2/Zope2Wiki Zope 2 Wiki]'''
+
: Main wiki page for all things related to Zope 2.
+
; '''[http://docs.zope.org docs.zope.org]'''
+
: This is the main site for Zope documentation.
+
  
== First Steps ==
+
{{#show:User:Drobbins|?Email|link=none}}
 +
{{#ask: [[Category:People]]
 +
| ? Full name
 +
| ? Nick
 +
| ? Role desc
 +
| ? Start date
 +
| ? Geoloc
 +
| format=template
 +
| template=TeamList
 +
| link=none
 +
}}
 +
{{#gravatar_img:drobbins@funtoo.org}}
 +
[[Special:MyPage]]
  
First, you will need to emerge {{Package|net-zope/zope}}:
+
{{Litecoin|blurb=Check it out: Mine litecoins for Funtoo!}}
<console>
+
###i## emerge -av zope
+
</console>
+
  
Zope is now installed.
+
blarg foo bar
 +
 +
{{#ask: [[Category:People]]
 +
| ? Full name
 +
| ? Geoloc
 +
}}
  
== Project Skeleton ==
+
{{#ask: [[Category:People]] [[Role type:Developer]]
 +
  |? Full name
 +
}}
  
{{Note}} Zope should be run by a regular user account, not as the root user.
+
#ask:
 
+
[[-Role type::Developer]]
The first step in using Zope is to ensure that you are using a regular user account. Create a new directory called <tt>zope_test</tt>:
+
| ?Geoloc
<console>
+
| ?Full Name
$##bl## cd
+
| format=map
$##bl## mkdir zope_test
+
| width=1000
</console>
+
| height=400
 
+
}}
Now, enter the directory, and create an "instance", which is a set of files and directories that are used to contain a Zope project:
+
<console>
+
$##bl## cd zope_test
+
$##bl## /usr/lib/zope-2.13/bin/mkzopeinstance
+
</console>
+
 
+
You will see the following output, and will be prompted to answer a few questions:
+
<console>
+
Please choose a directory in which you'd like to install
+
Zope "instance home" files such as database files, configuration
+
files, etc.
+
 
+
Directory: instance
+
Please choose a username and password for the initial user.
+
These will be the credentials you use to initially manage
+
your new Zope instance.
+
 
+
Username: admin
+
Password: ****
+
Verify password: ****
+
</console>
+
 
+
Now, we will start our Zope instance:
+
<console>
+
$##bl## cd instance
+
$##bl## bin/runzope
+
</console>
+
 
+
Now that Zope is running, you can visit <tt>localhost:8080</tt> in your Web browser. You will see a nice introductory page to Zope.
+
 
+
If you now go to the <tt>localhost:8080/manage</tt> URL, you will be prompted to log in. Enter the username and password you specified. You are now logged in to the ZMI (Zope Management Interface.)
+
 
+
You can stop your application by pressing Control-C. In the future, you can start and stop your Zope instance using the following commands:
+
 
+
<console>
+
$##bl## zopectl start
+
$##bl## zopectl stop
+
</console>
+
 
+
{{Note}} <tt>zopectl start</tt> will cause your instance to run in the background rather than consuming a shell console.
+
 
+
== First Project ==
+
 
+
We will create a single very primitive Zope package, consisting of an Interface for a TODO class, and a TODO class.
+
 
+
Create the following files and directories relative to your project root:
+
 
+
* Create the directory <tt>lib/python/example</tt>.
+
* Create the file <tt>lib/python/example/__init__.py</tt> by typing <tt>touch lib/python/example/__init__.py</tt>.
+
* Create these files:
+
 
+
=== <tt>example-configure.zcml</tt> ===
+
 
+
This file registers the <tt>example</tt> directory you created in <tt>lib/python</tt> as a ''package'', so that it is seen by Zope. Edit <code>/etc/package-includes/example-configure.zcml</code>:
+
{{File
+
|/etc/package-includes/example-configure.zcml|<pre>
+
<include package="example" />
+
</pre>}}
+
 
+
=== <tt>interfaces.py</tt> ===
+
 
+
The following file defines the <tt>ITODO</tt> interface, and also uses some Zope Schema functions to define what kind of data we expect to store in objects that implement <tt>ITODO</tt>. Edit <code>/lib/python/example/interfaces.py</code> with your favorite text editor:
+
 
+
<pre>
+
from zope.interface import Interface
+
from zope.schema import List, Text, TextLine, Int
+
 
+
class ITODO(Interface):
+
    name = TextLine(title=u'Name', required=True)
+
    todo = List(title=u"TODO Items", required=True, value_type=TextLine(title=u'TODO'))
+
    daysleft = Int(title=u'Days left to complete', required=True)
+
    description = Text(title=u'Description', required=True)
+
</pre>
+
 
+
=== <tt>TODO.py</tt> ===
+
 
+
Now, we define <tt>TODO</tt> to be a ''persistent'' object, meaning it can be stored in the ZODB. We specify that it implements our previously-defined <tt>ITODO</tt> interface, and provide reasonable defaults for all values when we create a new TODO object. Edit <code>/lib/python/example/TODO.py<code> using your favorite text editor:
+
<pre>
+
from persistent import Persistent
+
from zope.interface import implements
+
from example.interfaces import ITODO
+
 
+
class TODO(Persistent):
+
    implements(ITODO)
+
    name = u''
+
    todo = []
+
    daysleft = 0
+
    description = u''
+
</pre>
+
 
+
=== <tt>configure.zcml</tt> ===
+
 
+
Create the <tt>/lib/python/example/configure.zcml</tt> configuration file:
+
<pre>
+
<configure xmlns="http://namespaces.zope.org/zope"
+
    xmlns:five="http://namespaces.zope.org/five"
+
    xmlns:browser="http://namespaces.zope.org/browser">
+
</configure>
+
</pre>
+
 
+
== Debug Mode ==
+
 
+
We can test our first project by entering debug mode:
+
<console>
+
$##bl## bin/zopectl debug
+
Starting debugger (the name "app" is bound to the top-level Zope object)
+
</console>
+
 
+
Now, let's try creating a new TODO object and writing it out to a ZODB database:
+
<console>
+
>>> from ZODB import FileStorage, DB
+
>>> storage = FileStorage.FileStorage('mydatabase.fs')
+
>>> db = DB(storage)
+
>>> connection = db.open()
+
>>> import transaction
+
>>> root = connection.root()
+
>>> from example.TODO import TODO
+
>>> a = TODO
+
>>> a.name = u'My TODOs'
+
>>> a.TODOS = [ u'Do Laundry', u'Wash Dishes' ]
+
>>> a.daysleft = 1
+
>>> a.description = u'Things I need to do today.'
+
>>> root[u'today'] = a
+
>>> transaction.commit()
+
</console>
+
 
+
[[Category:HOWTO]]
+
[[Category:Featured]]
+

Revision as of 18:53, 23 September 2013

239


JSON

JSON




Funtoo / Gentoo Comparison (funtoo-current, x86-64bit)

  • x11-drivers/ati-drivers 14.6_beta1 > 14.4_p1
  • app-admin/salt 2014.1.7 > 2014.1.1
  • media-gfx/blender 2.71 > 2.70-r2
  • media-video/vlc 2.1.9999 > 2.1.5
  • sys-kernel/genkernel 9999-r1 > 3.4.40.7-r3
  • sys-cluster/ploop 1.11 > 1.10
  • mail-mta/postfix 2.12_pre20140703 > 2.11.1
  • app-vim/gentoo-syntax 20130619 > 20120916
  • sys-boot/grub 9999-r1 > 2.00-r7
  • sys-libs/glibc 2.19-r1 > 2.18-r1
  • sys-fs/lvm2 2.02.106 > 2.02.103
  • sys-fs/udev 215 > 171-r10
  • sys-fs/eudev 1.9 > 1.5.3-r2
  • dev-java/jython 2.7_beta2 > 2.7_beta1-r1
  • dev-libs/libgpg-error 1.13 > 1.12-r2
  • sys-apps/man-db 2.6.7.1 > 2.6.5
  • sys-apps/coreutils 8.22-r1 > 8.21
  • sys-apps/busybox 1.22.1 > 1.21.1
  • sys-apps/hwids 99999999 > 20140602
  • sys-apps/kmod 18-r1 > 15-r1
  • sys-devel/binutils 2.24-r3 > 2.23.2
  • sys-devel/gcc 4.8.3 > 4.8.2-r3
  • net-wireless/hostapd 2.2 > 2.0
  • www-servers/thin 1.6.2 > 1.5.1
  • app-portage/portage-utils 0.53 > 0.21-r1
  • app-misc/ca-certificates 20140223.3.16-r1 > 20140223.3.15.5
  • app-misc/screenfetch 3.2.2 > 3.0.5

Widgets

Loading map...



drobbins@funtoo.org

Special:MyPage

blarg foo bar

 Full nameGeoloc
0n0w1c35° 39' 10.1963", -97° 28' 41.1434"
404 Error46° 47' 15.7805", -71° 16' 44.8021"
666threesixes66642° 40' 48", -85° 24' 36"
Aaddame52° 2' 10.2588", 5° 9' 25.8588"
AbsmithAdam Smith38° 51' 56.9988", -76° 37' 13.0008"
Admirer48° 20' 15.8068", 15° 24' 12.3422"
AenesidemusOlexandr Burlaka50° 25' 18.5709", 30° 27' 55.5524"
AjchemistSeok Jin Seo35° 8' 42.4574", 126° 55' 47.2217"
Akai mirror55° 45' 4.4708", 37° 37' 6.3181"
Akiress30° 18' 21.1", -90° 58' 20.4899"
AlfredChenAlfred Chen23° 7' 44.9868", 113° 15' 51.966"
Aliceinwire35° 41' 22.155", 139° 41' 30.143"
AlinAlin Dobre51° 30' 40.37", -0° 7' 11.3678"
Amirouche43° 17' 47.3352", 5° 22' 11.208"
Anak1nanak1n c38° 18' 16.9999", -122° 17' 56"
Angelsystech-19° 55' 8.6437", -43° 56' 18.8689"
Aramis qc47° 2' 39.3806", -70° 57' 14.9069"
AramisqcGuy Fontaine46° 37' 43.7458", -71° 14' 7.2656"
ArianaAriana Strangelove40° 3' 45.72", -105° 16' 57.72"
Arkhan-0° 11' 3.2988", -78° 27' 51.6797"
Armanx14° 36' 33.8052", 121° 3' 18.4715"
Asqard49° 37' 2.8326", 20° 42' 55.1974"
Axel55° 45' 0", 37° 37' 12"
AzerthothJames Cook61° 20' 43.4882", -149° 33' 20.5564"
Balticer54° 9' 15.7045", 12° 3' 54.24"
Barnes22° 23' 47.1408", 114° 6' 34.1892"
Bazzle55° 57' 11.7072", -3° 11' 17.7612"
BhundvenBryan Hundven47° 36' 22.3542", -122° 19' 55.4549"
BiberaoMarco Dominguez41° 32' 43.615", -8° 25' 35.4252"
Bladewing49° 46' 46.452", 9° 57' 57.492"
BrantgurgaBrant Gurganus40° 0' 0.6502", -86° 9' 44.8585"
Budong-24° 57' 19.6211", -53° 27' 18.85"
BunykTaras Bunyk49° 50' 22.8588", 24° 1' 46.9812"
Calicojck44° 59' 0.0024", -93° 16' 0.012"
Camtt-35° 0' 17.136", 138° 41' 7.2168"
Carl.su25° 2' 16.836", 121° 33' 54.324"
Carlos-22° 0' 17.5366", -47° 53' 55.6899"
Ccooper34° 3' 12.186", -84° 36' 11.3072"
Changa49° 46' 38.8831", 18° 14' 7.3446"
Ciges42° 12' 49.1494", -8° 44' 28.7956"
CoffnixRaphael Bastos-19° 55' 50.9952", -43° 57' 9.0072"
CorlCor Legemaat-25° 48' 18", 28° 44' 47.0004"
Crater215049° 50' 7.0838", 9° 51' 44.3771"
CroutchFredrik Hede57° 42' 31.932", 11° 58' 28.416"
Cyball51° 27' 52.2324", 7° 54' 48.618"
Cyberian33° 11' 32.5062", 73° 6' 10.8984"
D2 racing46° 47' 5.1036", -71° 21' 18.0151"
D3zd3z32° 55' 17.63", -117° 8' 0.2688"
Da9h0st48° 53' 4.1874", 8° 19' 30.8111"
Daemonalec44° 58' 6.771", -93° 18' 28.9472"
… further results


  1. ask:

DeveloperValues cannot be assigned to inverse properties. | ?Geoloc | ?Full Name | format=map | width=1000 | height=400 }}