Re: Pixie and EO object issue

[prev] [thread] [next] [lurker] [Date index for 2004/06/25]

From: Steve Purkis
Subject: Re: Pixie and EO object issue
Date: 12:56 on 25 Jun 2004
Hi Dieter,

Yes I do remember you - hope you're doing well!

A quick look at this shows that you're using Clone's clone(), which I=20
assume comes from EO.  The short answer is:  don't use clone().

The long answer...

1. clone() breaks encapsulation -- Pixie expects you to use methods on=20=

the objects you store, it's unfortunately not magic enough to handle=20
direct-variable access at the moment, and that's effectively what=20
clone() does.

2. The error you're actually seeing is an internal Perl error -- 'man=20
perldiag'.   clone() uses Perl's internals to copy scalars, and thus it=20=

is fast.  Unfortunately the "Magic Scalars" that Pixie uses are not=20
registered with Perl's internal list of Magic, and so it dies.  I've=20
been tempted to patch Clone to work around this, but haven't had the=20
time.

So basically, if you write your own clone() using methods to access=20
variables & nested objects then Pixie will proxy everything for you the=20=

right way.  Alternatively, you could do this in all your classes:

	use constant px_is_immediate =3D> 1;

and then use Storable's dclone() which is slower, but doesn't try to=20
copy Pixie's Magic.  (see Pixie::Complicity for more details on=20
px_is_immediate).

As an aside, I noticed you've got TT2 in some of the paths you use --=20
James Duncan mentioned some issues using Pixie and Template Toolkit. =20
If you want more details I'd suggest dropping him a line.

Hope this helps,
-Steve

On Jun 24, 2004, at 10:05, Dieter M=FCcke wrote:

> Hello Steve,
> might be do you remember me. I'm a friend from Tosti and we have met=20=

> at London last year.
> I'm planning to use Pixie and was downloading latest version from =
CPAN.
> I derive my classes from James Duncans EO classes and use Pixie for=20
> making my objects persistent.
> After loading object from db I'm trying to clone it. While using=20
> method clone() I'm facing error messages below.
>
> I have attached a small script to reproduce error message.
>
> Do you have any idea or work-around to prevent it?
>
>
> cd /Users/mueck/eb/dev/TTL2/	# -*-compilation-*-
> Entering directory `/Users/mueck/eb/dev/TTL2/'
> /usr/bin/perl -w /Users/mueck/eb/dev/TTL2/pixie_test.pl
> Declaration of private attribute in package UNIVERSAL may clash with=20=

> future reserved word
> Declaration of abstract attribute in package UNIVERSAL may clash with=20=

> future reserved word
> CODE package attribute may clash with future reserved word: private at=20=

> /Library/Perl/5.8.1/EO.pm line 48
> CODE package attribute may clash with future reserved word: private at=20=

> /Library/Perl/5.8.1/EO.pm line 56
> Don't know how to handle magic of type \37777777633 at=20
> /Library/Perl/5.8.1/EO.pm line 81.
> Bus error
>
> Compilation exited abnormally with code 138 at Thu Jun 24 10:24:01
>
> <pixie_test.pl>
>
> System: iMac G4, Mac OSX Panther ,perl 5.8.1
>
>
>
> Kind regards,
> Dieter M=FCcke
> =3D^..^=3D=

Generated at 13:56 on 01 Jul 2004 by mariachi 0.52