[Zope-dev] persistence

2001-06-28 Thread Mark McEahern

I'm a Zope and Python newbie and I'm trying to utilize Persistence, but I've
seen two different ways:

import ZODB
from Persistence import Persistent

vs.

from Globals import Persistent

Are these different?  If so, which is "better"?  Please don't ask me to
define better.  ;-)

Thanks,

// mark


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] persistence

2001-06-28 Thread Michel Pelletier

On Thu, 28 Jun 2001, Mark McEahern wrote:

> I'm a Zope and Python newbie and I'm trying to utilize Persistence, but I've
> seen two different ways:
> 
>   import ZODB
>   from Persistence import Persistent
> 
> vs.
> 
>   from Globals import Persistent
> 
> Are these different?  If so, which is "better"?  Please don't ask me to
> define better.  ;-)

If you're just using Zope, both are acceptable.  If you are just using
ZODB, use the first.

-Michel


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] persistence

2001-06-28 Thread Stephan Richter

At 01:40 PM 6/28/01 -0700, Mark McEahern wrote:
>I'm a Zope and Python newbie and I'm trying to utilize Persistence, but I've
>seen two different ways:
>
> import ZODB
> from Persistence import Persistent

As Michel said, this is only for non-Zope use. In this case the 'import 
ZODB' statement does some funky stuff with the namespace. ;-) But I do not 
even attempt to understand that now. Next year maybe...

If anyone knows about some nice documentation discussing/explaining this 
behavior, could you post the link?

Regards,
Stephan

--
Stephan Richter
CBU - Physics and Chemistry Student
Web2k - Web Design/Development & Technical Project Management


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



[Zope-dev] persistence and lists

2002-09-18 Thread Arndt Droullier


Hello,
I´m working on a product which contains custom data in a list of multiple
dictionaries.
How can I save the list/dictionaries after changes? Persistence is enabled
(and works for other types), and "_p_changed" is set, also
get_transaction().commit() is called.

A second problem is that multiple instances of the product reference the
same list. So if I change the list of one of the instances the other
changes,
too.
The list and dictionaries are stored in a class variable(in the product)
and not global.

Thanks, Arndt.

___
DV electric [EMAIL PROTECTED] http://www.dvelectric.com
Fon 0221/2725782Fax 0221/2725783  Burgmauer 20,  50667 Köln
___


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] persistence and lists

2002-09-18 Thread Casey Duncan

Sounds like you are trying to persist a class attribute value. This is not 
possible because instance are persistent, not classes. This is also the 
reason that the values change over all the instances. You are changing a 
mutable attribute of the class in place.

I would suggest setting the value in the constructor of your objects, to make 
sure it is an instance attribute rather than a class attr.

This:

class foo:
   def __init__(self):
   self.alist = []

   def append(self ,v)
   self.alist.append(v) # changes instance attr
   self._p_changed = 1 # will work

Instead of:

class foo:
alist = []

def append(self ,v)
self.alist.append(v) # changes class(!) attr
self._p_changed = 1 # Will not work, the instance was not changed!

hth,

Casey

On Wednesday 18 September 2002 03:27 pm, Arndt Droullier wrote:
> Hello,
> I´m working on a product which contains custom data in a list of multiple
> dictionaries.
> How can I save the list/dictionaries after changes? Persistence is enabled
> (and works for other types), and "_p_changed" is set, also
> get_transaction().commit() is called.
> 
> A second problem is that multiple instances of the product reference the
> same list. So if I change the list of one of the instances the other
> changes,
> too.
> The list and dictionaries are stored in a class variable(in the product)
> and not global.
> 
> Thanks, Arndt.
> 
> ___
> DV electric [EMAIL PROTECTED] http://www.dvelectric.com
> Fon 0221/2725782Fax 0221/2725783  Burgmauer 20,  50667 Köln
> ___



___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] persistence and lists

2002-09-18 Thread Lennart Regebro

From: "Arndt Droullier" <[EMAIL PROTECTED]>
> How can I save the list/dictionaries after changes?

The easiest thing to do is to is to use PersistentMapping and
PersistentList.
Create them in __init__ with "self.dictionary = PersistentMapping()" instead
of setting them as a class attribute.



___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



[Zope-dev] Persistence Module Confustion (fwd)

2004-02-11 Thread D. Bickle

I am trying to import the MailHost module that has dependencies with the
Persistence package. The interpreter complains that it cannot load the
Persistence modules and when I examine the package there is no content or
modules.

How can I fix my code to resolve these dependencies?
Have the Persistence modules been deprecated?

Thanks,



___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


[Zope-dev] Persistence ( was Thread Safe Counting )

2001-02-11 Thread Jon Franz

>> Morten's product stores the counter's
>> value in a file on the filesystem, and so it doesn't cause the
>> Data.fs to grow.
>
>Hmmm, well, my counter above wouldn't cause the data.fs to grow all that
much,
>since it subclasses Persistent and so gets its own pickle jar.
>
>cheers,
>
>Chris

So subclassing persistent will avoid changes to the object being stored and 
roll-backable in the ZODB?  Nice!  Now, if only we could get this sort of 
store-in-place functionality on a more fine-grained level (like on
individual
properties) - we could avoid a lot of coding to prevent ZODB bloat with
simple
features.. Ie, if I were to make a 'persistent porperty' on a DTML method,
I could store counter information in that property without worry
of ZODB bloat.

Hrm... *Jon staes into the distance wondering how much will break
if he tries to implement a 'persistent' flag for properties*

~Jon


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] Persistence Module Confustion (fwd)

2004-02-12 Thread Dieter Maurer
D. Bickle wrote at 2004-2-11 11:16 -0800:
>I am trying to import the MailHost module that has dependencies with the
>Persistence package. The interpreter complains that it cannot load the
>Persistence modules and when I examine the package there is no content or
>modules.
>
>How can I fix my code to resolve these dependencies?

The "Persistence" module is "filled" by an import of "ZODB".

The documentation string in its "__init__.py" explains why this
is so.

-- 
Dieter

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] Persistence ( was Thread Safe Counting )

2001-02-11 Thread Chris Withers

Jon Franz wrote:
> 
> So subclassing persistent will avoid changes to the object being stored and
> roll-backable in the ZODB? 

NO! read the posting again... Subclassing from persistent is HOW you make things
live in the ZODB. However, objects that subclass Persistent get their own pickle
jar, and so only make the ZODB grow by the size of themselves and their
attributes each time they change. In my counter's case, that's not a lot :-)

> Now, if only we could get this sort of
> store-in-place functionality on a more fine-grained level (like on
> individual
> properties) - we could avoid a lot of coding to prevent ZODB bloat with
> simple
> features.. Ie, if I were to make a 'persistent porperty' on a DTML method,
> I could store counter information in that property without worry
> of ZODB bloat.

I wouldn't be surprised if something like this happens at some stage ;-)

cheers,

Chris

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



RE: [Zope-dev] Persistence ( was Thread Safe Counting )

2001-02-11 Thread Jon Franz

Ah! this makes more sense, the idea of persistent properties even 
fits with this idea, though a true write-in-place property might be 
even better for some applications ;)

Next time I'll read the whole thread and not the last post in it!

> -Original Message-
> From: Chris Withers [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, February 11, 2001 1:05 PM
> To: Jon Franz
> Cc: '[EMAIL PROTECTED]'
> Subject: Re: [Zope-dev] Persistence ( was Thread Safe Counting )
> 
> 
> Jon Franz wrote:
> > 
> > So subclassing persistent will avoid changes to the object 
> being stored and
> > roll-backable in the ZODB? 
> 
> NO! read the posting again... Subclassing from persistent is 
> HOW you make things
> live in the ZODB. However, objects that subclass Persistent 
> get their own pickle
> jar, and so only make the ZODB grow by the size of themselves 
> and their
> attributes each time they change. In my counter's case, 
> that's not a lot :-)
> 
> > Now, if only we could get this sort of
> > store-in-place functionality on a more fine-grained level (like on
> > individual
> > properties) - we could avoid a lot of coding to prevent 
> ZODB bloat with
> > simple
> > features.. Ie, if I were to make a 'persistent porperty' on 
> a DTML method,
> > I could store counter information in that property without worry
> > of ZODB bloat.
> 
> I wouldn't be surprised if something like this happens at 
> some stage ;-)
> 
> cheers,
> 
> Chris
> 

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



RE: [Zope-dev] Persistence ( was Thread Safe Counting )

2001-02-12 Thread Tres Seaver

Jon Franz <[EMAIL PROTECTED]> wrote
 
> Ah! this makes more sense, the idea of persistent properties even 
> fits with this idea, though a true write-in-place property might be 
> even better for some applications ;)

Two things:

 * Don't count on storing the hit counter as a separate, "persistence
   aware" object (i.e., with its own pickle jar) to avoid bloating
   your Data.fs.  Hit counters are by definition high volume, and the
   space overhead for managing undoable persistence is higher than
   you might think.

 * Write-in-place will never be supported by packable/undoable storages
   (logically impossible);  some "packless" storages are already in
   play (maybe even near release), so the semantics you want may be
   (soon) readily available by mounting a separate storage.

Tres.
-- 
===
Tres Seaver[EMAIL PROTECTED]
Digital Creations "Zope Dealers"   http://www.zope.org

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )