Re: [Zope3-Users] What attributes are made persistent

2006-02-15 Thread Jeff Shell
One could, but it's really not worth it. It's just the laws of Python
and mutability and immutability :). (It took me years to understand
those terms. I kept associating them with 'mutable' in the "can be
made quiet" sense... Eventually my music brain stepped back and I went
"oh, MUTATE! Ahhh!". Seriously, it took me about four years to
understand that :).

Anyways, it comes down to this. They're just different statements:

>>> compiler.parse("a.b = [1,2,3]")
Module(None, Stmt([Assign([AssAttr(Name('a'), 'b', 'OP_ASSIGN')],
List([Const(1), Const(2), Const(3)]))]))
>>> compiler.parse("a.b.extend([1,2,3])")
Module(None, Stmt([Discard(CallFunc(Getattr(Getattr(Name('a'), 'b'),
'extend'), [List([Const(1), Const(2), Const(3)])], None, None))]))

It's just easier to set the dirty bit yourself or use the persistent
object (or use the trick to re-assign after modifying).

Personally, I seldom store lists, or even use them as attributes on
instances. Even outside of Zope/ZODB, I've found myself accidentally
losing data because I was carelessly using the reference. Tuples for
everybody!

On 2/15/06, Shaun Cutts <[EMAIL PROTECTED]> wrote:
> Well, one could have a base class along the lines of
>
> class PersistSetItemOnAttributes:
>
> def __setattr__( self, attr, val ):
> oldSI = val.__class__.__dict__.get( '__setitem__', None )
> if oldSI is not None:
> def newSI( vself, vattr, vval ):
> vself._p_changed = True # is this the right member?
> oldSI( vattr, vval )# oldSI is bound: no vself?
> val.__class__.__setitem__ = newSI
> super( PersistSetItemOnAttributes, self ).__setattr__( attr, val
> )
>
> Of course, this is really just pseudocode. For one thing, need to trap
> whether 'val' is really a class. For another if you were serious about
> this, you would want to check if the obj wasn't persistent first, and
> you might want to do it recursively. And while your are at it, you might
> want to check on other mutators as well(for instance, check first
> what sequence interface if any 'val' supports...)
>
> ... sounds like too much work, and would be problem prone even so. After
> all, some things you don't want to be persistent!
>
> - Shaun
>
> > -Original Message-
> > From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> > On Behalf Of Stephan Richter
> > Sent: Wednesday, February 15, 2006 8:43 AM
> > To: zope3-users@zope.org
> > Cc: Florian Lindner
> > Subject: Re: [Zope3-Users] What attributes are made persistent
> >
> > On Wednesday 15 February 2006 08:21, Peter Bengtsson wrote:
> > > class PersistentAnything(PersistentMapping, PersistentList,
> > > PersistentDict):
> >
> > AA! This is so wrong! It merges two incompatible APIs: collections
> and
> > mappings. The non-persistent equivalent to this is:
> >
> >   >>> class DoEverything(set, list, dict):
> >   ...  pass
> >
> > > Am I just trying to make it too simple?
> >
> > I think you try far too hard to not understand why the persistent
> > mechanism
> > works as it does. You make your life harder than it has to be.
> >
> > Regards,
> > Stephan
> > --
> > Stephan Richter
> > CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
> > Web2k - Web Software Design, Development and Training
> > ___
> > Zope3-users mailing list
> > Zope3-users@zope.org
> > http://mail.zope.org/mailman/listinfo/zope3-users
>
>
>
> ___
> Zope3-users mailing list
> Zope3-users@zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users
>


--
Jeff Shell
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Please Guido, pick me, pick me!

2006-02-15 Thread Peter Simmons

Hi All,

I am pretty much an observer who has been to a sprint but just can't 
find the time in the commercial world to contribute to the code base but 
one who really believes in Zope 3 and have been using Zope 2 since its 
inception and convincing people that its a worthwhile framework while 
often getting frustrated with its magic and ways.


I agree with all the Joel's rant below was a great summary of the 
general discussion.


I would love to help with this and can organise some funding for 
people's time to putting this site together.


I haven't seen it before in the Zope 3 community but maybe we could 
start a thing on Fundable.org to get some money for this thing. Or would 
ZF be the place to approach about this? I am not really up with the play 
on where ZF is at and what its going to do.


Anyway my company could contribute $1000 NZD (about $700 USD at the 
moment) to this to get the ball rolling.


Should I try to organise this myself or is there already people 
responsible for this type of thing?


Cheers,
Pete

Joel Moxley wrote:


The Zope Foundation, which is probably coming pretty darn soon, might
help catalyze contributors a bit.  It will own the zope3.org domain,
the zope.org domain, and probably lots more, and all of the software.

But before or after the foundation, I think small steps are more
likely to succeed than grand plans.  Someone writing an impressive
brochure-ware site about Zope 3 is going to be easier and more
impressive than trying to get folks to agree on a grand Zope 3
software site.  Someone assembling some of the word-smithing in this
thread might even generate a simple impressive advocacy *page* that
could be linked to from the front of zope.org.  I thought Joel's post
had some ring to it, for instance.  Whether or not we have a "Zope 3:
Rebel Angel" rename :-), it would be great to see Joel or Martin or
someone step up to put some advocacy out there.  If I can help with
trying to figure out who to ask for what, let me know.
   



As I see it, Zope 3's central marketing issue is the lack of a
coherent online identity.  There needs to be a single place that
answers the following questions:

1) What is Zope 3?
2) Why use Zope 3?
3) How does Zope 3 compare to competing frameworks?
4) How do I get started?

Largely, this is assembly of the Zope 3 FrontPage, philikon's first
two chapters, and the "appetizer" quick start guides on worldcookery. 
However, I would also  love to see a section on the lead developers

answering Q1-Q3.  And this would be in conjunction with conveying...

Zope3's shtick:  Zope3 is not flashy.  Zope3 does not put pastel
colors on its website. Zope3 is the no-nonsense, industrial strength
platform.  It's where you come when you want to do it right.  It was
coded with the most rigorous standards by a bunch of hard-nosed sons
of bitches who don't have time for froofy marketing :).  And so forth.
This would come across in lead dev's answering Q1-Q3.

And finally, the site should demonstrate the "industrial strength"
quality with examples.  Little snippets from developers of SchoolTool,
corporate users, and so forth should demonstrate "hey, we're for real,
and we don't mess around -- you give me an animated screenshots, I
raise you a XYZ transaction per day uber site".  In a sense, we'd want
to portray ourselves as the Chuck Norris[1] of web platforms :)

Bottom line, a coherent online identity would go a long way.  Instead
of doing some snazzy marketings, let's communicate the character that
Zope3 does have.  It sounds like zope3.org under ZF might be the ideal
way to do this,

As for codenames, this is just one way we could help create a coherent
online identity.  I certainly think release names would be fun (and
not distracting to the central "Zope 3" brand we'd want).  Overall, I
think the time has come for communication of Zope 3 identity to move
hand in hand with development.

Joel

[1] For those not familiar with Chuck Norris, he's a no-nonsense
martial arts guy and the subject of these very amusing "facts".
http://www.4q.cc/chuck/index.php?topthirty
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

 


___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Swiss Easter Sprint - Announcement

2006-02-15 Thread Roger Ineichen
Swiss Easter Sprint

"Sorry for cross posting, I just will make sure that 
nobody feels like not invited and has a chance to 
participate."


When

The sprint starts on Saturday, April 8, at 9:00am and will end 
on Wednesday, April 12 in the afternoon. The official welcome 
activity will be at noon on April 8.


Where

The workshop will be located in Cham. Cham is a Town near Zug, 
Switzerland. Yeah, Zug is a town and doesn't mean Zope User Group!
http://www.cham.ch/de/portrait/sehenswuerdigkeiten


What

Zope 3 Strategy Workshop

The future of Zope 3 and its role for other frameworks

With the recent interest of the wider community in Zope 3, it is important
to define Zope 3 in light of this. Discussions could be held about what
should be the Zope 3 core, how can other development shape the core and how
Zope 3 can best support high-level frameworks, such as Cubed.

In previous sprints we have also worked on a new face for Zope 3, a new Web
site. This and other Zope 3 marketing material could be developed during the
sprint, making the event also interesting for non-developers. It would be
really great to have a Zope 3 "promotion" leam at the sprint.

This is a great opportunity for Zope 3 core developers and framework
builders to meet and have discussions. We will define more concrete topics
to work on and discuss as we come closer to the sprint date.

Zope 3 Core Development

We have recently seen and will see a lot of reorganization of the
core. However, a lot of the changes (with exception of Jim's adapter
registry rewrite) are cosmetic, leaving some tougher technical challenges
open. Since this sprint will be a true Zope 3 sprint, we could address some
really hard-core issues, like menues, new widget package, formlib work,
etc. The actual topics will depend on the participants, of course.

Zope 3 Experimentation

Recently, there have been several experimental packages under development,
like the boston skin and the WebDev package while others have been proposed
like Shane's Web root or indirection tool. While not directly usable in a
release, this research work is necessary to give Zope 3 the cutting edge in
the future.


You can register yourself on the sprint page at:
http://www.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/SwissEaster
Sprint


Or send me a mail if you don't have access for editing the Wiki-Page
and add yourself to the participant list.

Regards
Roger Ineichen
_
Projekt01 GmbH
www.projekt01.ch
Langackerstrasse 8
6330 Cham
phone +41 (0)41 781 01 78
mobile+41 (0)79 340 52 32
fax   +41 (0)41 781 00 78
email [EMAIL PROTECTED]
_
END OF MESSAGE 

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Zope 3 Developer's LiveBook

2006-02-15 Thread Igor Stroh
Igor Stroh wrote:
> Reinoud van Leeuwen wrote:
> 
>>On Tue, Feb 14, 2006 at 09:15:42PM +0100, Florian Lindner wrote:
>>
>>
>>>I also think that pure Latex would be the best choice. It's convertible into 
>>>a 
>>>lot different formats and can be edited just using a simple text editor.
>>
>>
>>Isn't Docbook a better choice? Is is specially designed for documents like 
>>this, and easily parsable. lots of tools around. 
>>It can (AFAIK) be read and written by Open Office or any text editor. 
> 
> 
> +1
> 
> DocBook is definitely a better choice, there's db2latex for LaTeX
> (and PDF) conversion and various XSLT stylesheets for HTML.

To prove this statement, I've created a simple source tree that can
be used to automate the whole process:

z3lb-docbook/
|-- Makefile
|-- html-styles.xsl
|-- src/
|   |-- intro.xml
|   |-- new_chapter.py
|   |-- z3livebook.css
|   `-- z3livebook.xml
`-- tex-styles.xsl

Just run `make html` or `make pdf` to produce HTML or PDF respectively.

Dependencies (as Debian packages):
   o docbook-xml (pdf+html)
   o tetex-bin (pdf)
   o xsltproc (pdf+html)
   o docbook-xsl (html)

I'm using a similar setup to write my diploma thesis, so far it
works quite well.

Cheers,
Igor

P.S.:
"DocBook - The Definitive Guide"
http://www.docbook.org/tdg5/en/html/docbook.html


z3lb-docbook.tar.gz
Description: GNU Zip compressed data
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: Zope 3 Developer's LiveBook

2006-02-15 Thread Fred Drake
On 2/15/06, Philipp von Weitershausen <[EMAIL PROTECTED]> wrote:
> I've never tried using OpenOffice and I'm not sure whether
> its changes would actually leave existing whitespace intact (this would
> be crucial for decent diffs).

I've worked a bit with generating OpenDocument documents for use with
OpenOffice, and have no expectation that the document will be edited
in a way that a plain-text user will be happy with.  Since the files
are ZIP files that contain XML, it's not like supporting plain text
users is a use-case for OpenDocument.


  -Fred

--
Fred L. Drake, Jr.
"There is no wealth but life." --John Ruskin
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


RE: [Zope3-Users] Lists dont accept default values

2006-02-15 Thread Shaun Cutts
Frank,

I'm not sure how widgets manage to get default values; I know that
zope.schema itself doesn't set them.

There is further problem with the design for "default" -- see discussion
of "default_factory" on zope3-dev: basically, even if the widget were to
get this default, it would be *the* list for every implementation of
IMyContent (not *a* list with these default values). Maybe for this very
reason the widget ignores the default.

Ideally (in my opinion) there would be a default_factory attribute for
mutable schema objects, and spec of the list would be:

default_factory = lambda : list( ( 1,2,3,5,7 ) )  # new every time,
right?

That said, if these defaults are taken out of a finite universe then
Florian's response is correct.

- Shaun




___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


RE: [Zope3-Users] What attributes are made persistent

2006-02-15 Thread Shaun Cutts
Well, one could have a base class along the lines of

class PersistSetItemOnAttributes:

def __setattr__( self, attr, val ):
oldSI = val.__class__.__dict__.get( '__setitem__', None )
if oldSI is not None:
def newSI( vself, vattr, vval ):
vself._p_changed = True # is this the right member?
oldSI( vattr, vval )# oldSI is bound: no vself?
val.__class__.__setitem__ = newSI
super( PersistSetItemOnAttributes, self ).__setattr__( attr, val
)

Of course, this is really just pseudocode. For one thing, need to trap
whether 'val' is really a class. For another if you were serious about
this, you would want to check if the obj wasn't persistent first, and
you might want to do it recursively. And while your are at it, you might
want to check on other mutators as well(for instance, check first
what sequence interface if any 'val' supports...)

... sounds like too much work, and would be problem prone even so. After
all, some things you don't want to be persistent!

- Shaun
 
> -Original Message-
> From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
> On Behalf Of Stephan Richter
> Sent: Wednesday, February 15, 2006 8:43 AM
> To: zope3-users@zope.org
> Cc: Florian Lindner
> Subject: Re: [Zope3-Users] What attributes are made persistent
> 
> On Wednesday 15 February 2006 08:21, Peter Bengtsson wrote:
> > class PersistentAnything(PersistentMapping, PersistentList,
> > PersistentDict):
> 
> AA! This is so wrong! It merges two incompatible APIs: collections
and
> mappings. The non-persistent equivalent to this is:
> 
>   >>> class DoEverything(set, list, dict):
>   ...  pass
> 
> > Am I just trying to make it too simple?
> 
> I think you try far too hard to not understand why the persistent
> mechanism
> works as it does. You make your life harder than it has to be.
> 
> Regards,
> Stephan
> --
> Stephan Richter
> CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
> Web2k - Web Software Design, Development and Training
> ___
> Zope3-users mailing list
> Zope3-users@zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users



___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] What attributes are made persistent

2006-02-15 Thread Lennart Regebro
On 2/15/06, Peter Bengtsson <[EMAIL PROTECTED]> wrote:
> D'oh! That's confusing. Isn't there a class that gathers all of these in one.

All of who?

> It seems confusing, you derive from Persistent but only some are accepted.
> Does that mean that there's PersistentFloat and PersistentTuple too?

Because floats and tuples are not mutable. You can't change them, so
the don't need to know that they should be persisted when changed.

> If not, why *only* dicts?

There is also PersistentList.

--
Lennart Regebro, Nuxeo http://www.nuxeo.com/
CPS Content Management http://www.cps-project.org/
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Lists dont accept default values

2006-02-15 Thread Florian Lindner
Am Mittwoch, 15. Februar 2006 14:40 schrieb Frank Burkhardt:
> Hi,
>
> I wrote a schema like this to have a list of objects on a content object:
>
>  class IMyContent(Interface):
> mynumbers=List(
>title=_(u"Cool Numbers"),
>required=True,
>value_type=Int(
>   title=_("integer")
>)
>default=[1,2,3,5,7]
> )

I think the default property expects one item of your list, so either 1, 2, 3, 
5 or 7, not all of them.
If you want to define the set of selectable values you maybe rather want to 
use a Choice field and specify the values property. Or set a Choice field as 
value for value_type.
See Stephans book [1], chapther 8.3 Core Schema Fields

[1] 
http://www.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/FrontPage/Zope3Book

Regards,

Florian


> myline=TextLine(
>title=_("A line of text"),
>required=True,
>default=u'default test'
> )
>
> I'm using an 'addform' to add self made objects to my site but
> unfortunately the list mynumbers is not initialized with those 5 default
> numbers. The default value of myline is displayed correctly on the add
> form.
>
> Does anyone know, how this can be fixed?
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] What attributes are made persistent

2006-02-15 Thread Peter Bengtsson
On 2/15/06, Paul Winkler <[EMAIL PROTECTED]> wrote:
> On Wed, Feb 15, 2006 at 01:21:14PM +, Peter Bengtsson wrote:
> > I understand the mutation stuff and I always do it like this in zope2
> > (I'm a complete beginner in the zope3 world eager to learn):
> >
> > def updatesometing(self):
> >#self.numbers['Peter'] = "0779 123 456"
> >numbers = self.numbers
> >numbers['Peter'] = "0779 123 456"
> >self.numbers = numbers
> >
> > But in zope2 land, if I derive from Persistent it magically saves ALL
> > attributes defined in __init__ assuming that I post-write to them
> > correct as shown above.
>
> That hasn't changed in zope 3.  This is just standard ZODB behavior.
> setattr will cause a save on commit regardless of the type of
> the value.  If you read Jeff's reply again carefully, he said as much.
>
> PersistentList and PersistentDict are not new, either.
> They've been used in Zope 2 projects for ages.
>
> There are still exactly three ways to get sub-object mutations to
> persist:
>
> 1) Set the "dirty bit" by hand, e.g.:
>
>  self.alist.append(1)
>  self._p_changed = 1
>
> 2) Re-assign the attribute, e.g.:
>
>  alist = self.alist
>  alist.append(1)
>  self.alist = alist
>
> 3) Using a persistent sub-object, e.g. a PersistentList instance:
>
>  self.alist.append(1)
>


Now I get it! Sorry for being slow and thanks for explaining.

So by using PersistentList it just means that you can use:
 self.alist.append(1)
in your code. The attribute, self.alist, is still saved even without
PersistentList but it just means you have to be careful when writing
to it.

Cool!

--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Re: Zope 3 Developer's LiveBook

2006-02-15 Thread Philipp von Weitershausen
Fred Drake wrote:
>>So with that in mind, if you do not know how to do professional desktop
>>publishing, then LaTeX is a much better options, since it results look really
>>professional.
> 
> We also have lots of cool support for Python documentation in LaTeX,
> which makes it really easy to work with after learning only some
> basics of LaTeX.

I wish the standard library was using reST.

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Re: Zope 3 Developer's LiveBook

2006-02-15 Thread Philipp von Weitershausen
Reinoud van Leeuwen wrote:
>>I also think that pure Latex would be the best choice. It's convertible into 
>>a 
>>lot different formats and can be edited just using a simple text editor.
> 
> Isn't Docbook a better choice? Is is specially designed for documents like 
> this, and easily parsable. lots of tools around. 
> It can (AFAIK) be read and written by Open Office or any text editor. 

I have used and continue to happily use DocBook for my book. I indeed
use db2latex to convert it to LaTeX because that's what the publisher
wants. You can also easily create HTML, manpages or PDFs (via XSL-FO).

I use emacs and nxml-mode to edit DocBook. nxml-mode gives me on-the-fly
validation and schema-based auto-completion. It makes me very
productive. I've never tried using OpenOffice and I'm not sure whether
its changes would actually leave existing whitespace intact (this would
be crucial for decent diffs).

By the way (1), I would very much recommend against LaTeX. I don't think
everyone knows how to use it properly (I sure don't). I also think it
does too much at a time (being a typesetting tool that also stores the
content you're trying to typeset). With DocBook or similar formats, you
can edit what matters, the content, and worry about what it's going to
look like later.

By the way (2), I also don't totally agree with Stephan on reST. I think
reST is a powerful tool and often underestimated. When parsing reST
text, docutils builds a DOM-like object structure which can easily be
serialized into XML and then to anything. The standard rst2html and
rst2latex scripts provided by docutils are only two possibilities. The
thought of switching my book to reST has crossed my mind two or three
times even, but for now I'm staying with the technology that I know and
that works.

Philipp

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] What attributes are made persistent

2006-02-15 Thread Paul Winkler
On Wed, Feb 15, 2006 at 01:21:14PM +, Peter Bengtsson wrote:
> I understand the mutation stuff and I always do it like this in zope2
> (I'm a complete beginner in the zope3 world eager to learn):
> 
> def updatesometing(self):
>#self.numbers['Peter'] = "0779 123 456"
>numbers = self.numbers
>numbers['Peter'] = "0779 123 456"
>self.numbers = numbers
> 
> But in zope2 land, if I derive from Persistent it magically saves ALL
> attributes defined in __init__ assuming that I post-write to them
> correct as shown above.

That hasn't changed in zope 3.  This is just standard ZODB behavior.
setattr will cause a save on commit regardless of the type of
the value.  If you read Jeff's reply again carefully, he said as much.

PersistentList and PersistentDict are not new, either.
They've been used in Zope 2 projects for ages.

There are still exactly three ways to get sub-object mutations to
persist:

1) Set the "dirty bit" by hand, e.g.:

 self.alist.append(1)
 self._p_changed = 1

2) Re-assign the attribute, e.g.:

 alist = self.alist
 alist.append(1)
 self.alist = alist

3) Using a persistent sub-object, e.g. a PersistentList instance:

 self.alist.append(1) 

-- 

Paul Winkler
http://www.slinkp.com
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Zope 3 Developer's LiveBook

2006-02-15 Thread Fred Drake
On 2/15/06, Stephan Richter <[EMAIL PROTECTED]> wrote:
> So with that in mind, if you do not know how to do professional desktop
> publishing, then LaTeX is a much better options, since it results look really
> professional.

We also have lots of cool support for Python documentation in LaTeX,
which makes it really easy to work with after learning only some
basics of LaTeX.


  -Fred

--
Fred L. Drake, Jr.
"There is no wealth but life." --John Ruskin
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] What attributes are made persistent

2006-02-15 Thread Stephan Richter
On Wednesday 15 February 2006 08:21, Peter Bengtsson wrote:
> class PersistentAnything(PersistentMapping, PersistentList,
> PersistentDict):

AA! This is so wrong! It merges two incompatible APIs: collections and 
mappings. The non-persistent equivalent to this is:

  >>> class DoEverything(set, list, dict):
  ...  pass

> Am I just trying to make it too simple?

I think you try far too hard to not understand why the persistent mechanism 
works as it does. You make your life harder than it has to be.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Lists dont accept default values

2006-02-15 Thread Frank Burkhardt
Hi,

I wrote a schema like this to have a list of objects on a content object:

 class IMyContent(Interface):
mynumbers=List(
   title=_(u"Cool Numbers"),
   required=True,
   value_type=Int(
title=_("integer")
   )
   default=[1,2,3,5,7]
)
myline=TextLine(
   title=_("A line of text"),
   required=True,
   default=u'default test'
)

I'm using an 'addform' to add self made objects to my site but unfortunately
the list mynumbers is not initialized with those 5 default numbers. The
default value of myline is displayed correctly on the add form.

Does anyone know, how this can be fixed?

Regards,

Frank
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] What attributes are made persistent

2006-02-15 Thread Peter Bengtsson
-- Forwarded message --
From: Peter Bengtsson <[EMAIL PROTECTED]>
To: Jeff Shell <[EMAIL PROTECTED]>
Date: Wed, 15 Feb 2006 13:14:58 +
Subject: Re: [Zope3-Users] What attributes are made persistent
On 2/15/06, Jeff Shell <[EMAIL PROTECTED]> wrote:
> On 2/14/06, Peter Bengtsson <[EMAIL PROTECTED]> wrote:
> > D'oh! That's confusing. Isn't there a class that gathers all of these in 
> > one.
> >
> > It seems confusing, you derive from Persistent but only some are accepted.
> > Does that mean that there's PersistentFloat and PersistentTuple too?
> > If not, why *only* dicts?
>
> As mentioned above, it applies to *mutable* objects.
>

>
> Instances of Persistent based classes know when they change. Like if you do::
>
> clive.age = 28
>

>
> On the other hand, if you do::
>
> clive.favoriteNumbers.append(13)
>
> 'clive' does not change. 'favoriteNumbers' changes. If favoriteNumbers
> is a regular Python list, the persistence machinery has no idea that
> it's changed. It's not being assigned to 'clive', it's already an
> attribute there and is not being replaced. So if it's not a
> PersistentList, it gets forgotten.
>

>
> It's not only dicts, it's dicts and lists (PersistentDict and PersistentList).
>
> I don't know if there's a PersistentSet. Python offers two sets since
> 2.3 - a mutable (list-like) one and an immutable (tuple-like) one. I
> imagine that if you use the mutable set (``sets.Set`` in 2.3, ``set``
> in 2.4), you'd run into the same problems. But if you used the
> immutable set (``sets.ImmutableSet``, ``frozenset`` in 2.4) you
> wouldn't.
>

>
> So - just use PersistentList and PersistentDict (or look into BTrees
> for better storage options).
>
> For more details, visit the ZODB documentation on ZODB programming,
> and visit the section on modifying mutable objects:
>
> http://www.zope.org/Wikis/ZODB/FrontPage/guide/node3.html
>

I understand the mutation stuff and I always do it like this in zope2
(I'm a complete beginner in the zope3 world eager to learn):

def updatesometing(self):
   #self.numbers['Peter'] = "0779 123 456"
   numbers = self.numbers
   numbers['Peter'] = "0779 123 456"
   self.numbers = numbers

But in zope2 land, if I derive from Persistent it magically saves ALL
attributes defined in __init__ assuming that I post-write to them
correct as shown above.

I like this simplicity and was hoping to find it in zope3 land too. I
guess I'm just an old dog and if I want to drag with me the zope2 way
I can do this::

import persistent.mapping.PersistentMapping
import persistent.list.PersistentList
import persistent.dict.PersistentDict

class PersistentAnything(PersistentMapping, PersistentList, PersistentDict):

I'm aware of BTrees and am/will always use it when size of objects
becomes "uncontrollable".

Am I just trying to make it too simple? Have I read one too many books
by Steve Krug?

--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Zope 3 Developer's LiveBook

2006-02-15 Thread Stephan Richter
On Wednesday 15 February 2006 03:38, Chris Withers wrote:
> I find it ironic the one of the first uses of PCs was to do word
> processing, and yet we seem to always strive to edit plain text of one
> variety or another, and yes, that includes latex ;-)

That's because Word Processors just do not have the layout quality that is 
required for professional printed media. I would say that desktop publishing 
software like Quark and Indesign (and now even Scribus) have been extremely 
successful.

Word processors do a good job when it comes to editing, since they provide 
spell/grammar checker, comments and change tracking. And that is how they are 
used by a lot of publishers. But in order to generate a book, publishers have 
import programs from Word to their desktop publishing software.

So with that in mind, if you do not know how to do professional desktop 
publishing, then LaTeX is a much better options, since it results look really 
professional.

I have more examples, but that's for another E-mail.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Squid/Apache Caching

2006-02-15 Thread Chris Withers

Peter Bengtsson wrote:

That's very interesting. If you understood Squid better do you think
you'd leave out apache? 


Maybe, I guess I just have a soft spot for Apache though ;-)


And what about the performance overhead? Any experience you can share?


Nope, Plone gives me all the performance overhead I need...

Chris

--
Simplistix - Content Management, Zope & Python Consulting
   - http://www.simplistix.co.uk

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] What attributes are made persistent

2006-02-15 Thread Chris Withers

Peter Bengtsson wrote:

self.queue seem is empty each time I restart Zope.

That's because dictionaries are not derived from Persistent. Try PersistentDict.


D'oh! That's confusing. Isn't there a class that gathers all of these in one.


Urm, Peter, the rules of persistence w.r.t. mutable objects have been 
documented for a _long_ time. There's nothing Zope 3-specific here, and 
someone who's been using Zope as long as you should know better ;-)


Chris

--
Simplistix - Content Management, Zope & Python Consulting
   - http://www.simplistix.co.uk

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Zope 3 Developer's LiveBook

2006-02-15 Thread Chris Withers

Reinoud van Leeuwen wrote:

On Tue, Feb 14, 2006 at 09:15:42PM +0100, Florian Lindner wrote:
I also think that pure Latex would be the best choice. It's convertible into a 
lot different formats and can be edited just using a simple text editor.


Isn't Docbook a better choice? Is is specially designed for documents like 
this, and easily parsable. lots of tools around. 
It can (AFAIK) be read and written by Open Office or any text editor. 


If I can use a real word processor to edit stuff (ie: OpenOffice) then 
I'd much prefer to see this...


I find it ironic the one of the first uses of PCs was to do word 
processing, and yet we seem to always strive to edit plain text of one 
variety or another, and yes, that includes latex ;-)


Chris

--
Simplistix - Content Management, Zope & Python Consulting
   - http://www.simplistix.co.uk

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users