|
Server : Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/1.0.0-fips mod_auth_passthrough/2.1 mod_bwlimited/1.4 System : Linux server.jackjohnson.com 2.6.32-279.5.2.el6.x86_64 #1 SMP Fri Aug 24 01:07:11 UTC 2012 x86_64 User : jackjohn ( 502) PHP Version : 5.3.17 Disable Function : NONE Directory : /usr/share/system-config-network/netconfpkg/ |
Upload File : |
Ñò
åOÜLc @ sÀ d Z d d k Z d d k l Z l Z d „ Z e d „ ƒ Z e d „ ƒ Z d e f d „ ƒ YZ d
e f d „ ƒ YZ d e f d
„ ƒ YZ
d e e f d „ ƒ YZ e Z
e Z e Z d S( s" Basic classes with predefined properties
Example usage:
class Article(Gdtstruct):
"A basic Article class"
# fields and types are dynamically set by the initializer
gdtstruct_properties([('title', Gdtstr, "The Title of the Article"),
('page', Gdtlist, "List of pages in the Article")
])
def __init__(self, *args):
super(Article, self).__init__(*args)
self.title = Gdtstr("")
self.page = Gdtlist()
class Page(Gdtstruct):
# fields and types are dynamically set by the initializer
gdtstruct_properties([('text', Gdtstr, "The text of the page"),
])
def __init__(self, *args):
super(Page, self).__init__(*args)
self.text = Gdtstr(args[0] if len(args) else "")
a = Article()
print Article.title.__doc__
print
a.title = "My title"
a.page.append(Page("page 1"))
a.page.append(Page("page 2"))
a.commit()
print a
print
a.title = "My bad title"
a.page[1].text = "bad page 2"
a.page.append(Page("bad page 3"))
print a
print
a.page.rollback()
print a
print
a.rollback()
print a
Output of the example:
The Title of the Article
Article.title=My title
Article.page.1.Page.text=page 1
Article.page.2.Page.text=page 2
Article.title=My bad title
Article.page.1.Page.text=page 1
Article.page.2.Page.text=bad page 2
Article.page.3.Page.text=bad page 3
Article.title=My bad title
Article.page.1.Page.text=page 1
Article.page.2.Page.text=page 2
Article.title=My title
Article.page.1.Page.text=page 1
Article.page.2.Page.text=page 2
iÿÿÿÿNi ( t Transactiont Transactionlistc sC ‡ f d † } ˆ i | _ ˆ i | _ ˆ i | _ ˆ i | _ | S( s6 basic idea stolen from zope.interface.advice, P.J. Ebyc s‰ t i d ƒ } d | i j oY d | i i j oF d | i j o t d ƒ ‚ n ‡ ‡ ‡ f d † } | | i d <n ˆ ˆ ˆ Ž d S( Ni t
__module__t
__metaclass__sZ Don't use two class initializers or
a class initializer together with a __metaclass__ hookc su y t | | | ƒ } WnH t j
o<