Remember to build a dictionary of all serialized objects, to be used to see
if a object has already been serialized. That way if you have refrence loops
you wont get recursion.

Also, it is advisable to implement a protocol that notifies all objects that
have been de-serialized when the whole "tree" has completed loading from the
saved state - that way if you have any wakeup code that has to execute you
are guaranteed that all objects are ready to be messaged...

Hardy

----- Original Message ----- 
From: "Paul Johnston" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, September 24, 2003 9:34 AM
Subject: RE: [CFCDev] Serialize?


> How about writing a serialize and deserialize method in the
> WEB-INF.cftags.component cfc? Then all cfc's you write will contain this
> method and you can then just call serialize and deserialize for any cfc
you
> write!
>
> Paul
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of Nathan Dintenfass
> > Sent: 24 September 2003 04:54
> > To: [EMAIL PROTECTED]
> > Subject: Re: [CFCDev] Serialize?
> >
> >
> > Keep in mind that Variables scope inside a CFC contains not
> > only your "instance" data but also the "THIS" scope and all
> > the methods of the CFC. It's one of the reasons I have
> > continued to use "variables.instance" for my instance data (I
> > too use a similar method to the one Barney talks about to
> > serialize and store the information I need to remake a
> > component) -- I can then just serialize "instance" instead of
> > worrying about the other "junk" in "Variables".
> >
> > The reason this matters in your case is that if you just
> > serialize "Variables" your packets could end up being quite a
> > bit larger than you want them to be (or than they need to be).
> >
> > If you don't want to use "instance" (or whatever name) you
> > can always loop through "Variables" and only store things
> > that aren't "THIS" or methods.
> >
> >
> >
> >
> > > From: "Barney Boisvert" <[EMAIL PROTECTED]>
> > > Reply-To: [EMAIL PROTECTED]
> > > Date: Tue, 23 Sep 2003 16:28:55 -0700
> > > To: <[EMAIL PROTECTED]>
> > > Subject: RE: [CFCDev] Serialize?
> > >
> > > You'll have to searialize the sub-CFCs indivudually.
> > >
> > > So you'll actually want something like this (forgive the
> > mixed syntax,
> > > typing tags for everything takes too long):
> > >
> > > function serialize() {
> > > result = structNew();
> > > result.CFC = structNew();
> > > result.nonCFC = structNew();
> > > for (i in variables) {
> > >   if (isObject(variables[i], "WEB-INF.cftags.component")) {
> > >     result.CFC[i] = variables[i].serialize();
> > >   } else {
> > >     result.nonCFC[i] = variables[i];
> > >   }
> > > }
> > > <cfwddx action="cfml2wddx" input="#result#" output="temp" /> return
> > > temp; }
> > >
> > > Your deserialize() function would have to change as well,
> > of course,
> > > but would follow a similar pattern.
> > >
> > >
> > >> -----Original Message-----
> > >> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> > >> Behalf Of Justin Balog
> > >> Sent: Tuesday, September 23, 2003 4:14 PM
> > >> To: '[EMAIL PROTECTED]'
> > >> Subject: RE: [CFCDev] Serialize?
> > >>
> > >>
> > >> That's a cool idea, will the variable ref work if your cfc is
> > >> composed of cfcs?  Or will I have to serialize them individually?
> > >>
> > >>
> > >> Thanks,
> > >>
> > >> Justin
> > >>
> > >> -----Original Message-----
> > >> From: Barney Boisvert [mailto:[EMAIL PROTECTED]
> > >> Sent: Tuesday, September 23, 2003 4:58 PM
> > >> To: [EMAIL PROTECTED]
> > >> Subject: RE: [CFCDev] Serialize?
> > >>
> > >>
> > >> You can't serialize an entire CFC directly, because it's
> > made up of
> > >> more than just data.  The way I'd do it is to have a
> > serialize() and
> > >> deserialize() method in your CFC.  The first will take the CFC's
> > >> internal state, wrap it up in whatever way you deem fit,
> > and return a
> > >> WDDX packet of that data, which can be stored however.  The
> > >> deserialize() method would take
> > >> that WDDX packet, and revert the CFC to the stored state.
> > If you're using
> > >> 6.1, you should be able to just do the whole variables scope.
> > >>
> > >> <cfcomponent name="Serializer">
> > >>   <cffunction name="serialize" ...>
> > >>     <cfset var result = "" />
> > >>     <cfwddx action="cfml2wddx" input="#variables#"
> > output="result" />
> > >>     <cfreturn result />
> > >>   </cffunction>
> > >>
> > >>   <cffunction name="deserialize" ...>
> > >>     <cfargument name="data" ... />
> > >>     <cfset var temp = "" />
> > >>     <cfset var i = "" />
> > >>     <cfwddx action="wddx2cfml" input="#arguments.data#"
> > output="temp" />
> > >>     <cfloop collection="#temp#" item="i">
> > >>       <cfset variables[i] = temp[i] />
> > >>     </cfloop>
> > >>   </cffunction>
> > >>
> > >>   <!--- other methods --->
> > >> </cfcomponent>
> > >>
> > >> To use it, you'd do something like this:
> > >>
> > >> <cfscript>
> > >> one = createObject("component", "Serializer");
> > >> one.init();
> > >> one.doSomething();
> > >> wddx = one.serialize();
> > >>
> > >> two = createObject("component", "Serializer");
> > two.deserialize(wddx);
> > >>
> > >> // now 'two' has the exact same state as 'one'
> > >> </cfscript>
> > >>
> > >>
> > >>
> > >>> -----Original Message-----
> > >>> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> > >>> Behalf Of Justin Balog
> > >>> Sent: Tuesday, September 23, 2003 3:34 PM
> > >>> To: '[EMAIL PROTECTED]'
> > >>> Subject: [CFCDev] Serialize?
> > >>>
> > >>>
> > >>>
> > >>> I don't even know if I am using the correct term?  Is there a
> > >> quick way to
> > >>> serialize a cfc, say in to a WDDX packet?  Basically, I
> > want to take
> > >>> an instance of a cfc and write it to a file in a meaningful way
> > >> (i.e. WDDX or
> > >>> XML) in case there is a dB error or ODBC connection failure.
> > >> Any thoughts
> > >>> on how to do this without having to call all the
> > getters/setters of
> > >>> the object itself.
> > >>>
> > >>>
> > >>> Thanks,
> > >>>
> > >>> Justin
> > >>> ----------------------------------------------------------
> > >>> You are subscribed to cfcdev. To unsubscribe, send an email to
> > >>> [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' in the
> > >>> message of the email.
> > >>>
> > >>> CFCDev is run by CFCZone (www.cfczone.org) and supported
> > >>> by Mindtool, Corporation (www.mindtool.com).
> > >>>
> > >>> An archive of the CFCDev list is available at
> > >> www.mail-archive.com/[EMAIL PROTECTED]
> > >>
> > >> ----------------------------------------------------------
> > >> You are subscribed to cfcdev. To unsubscribe, send an email to
> > >> [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' in the
> > >> message of the email.
> > >>
> > >> CFCDev is run by CFCZone (www.cfczone.org) and supported
> > >> by Mindtool, Corporation (www.mindtool.com).
> > >>
> > >> An archive of the CFCDev list is available at
> > >> www.mail-archive.com/[EMAIL PROTECTED]
> > >> ----------------------------------------------------------
> > >> You are subscribed to cfcdev. To unsubscribe, send an email to
> > >> [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' in the
> > >> message of the email.
> > >>
> > >> CFCDev is run by CFCZone (www.cfczone.org) and supported
> > >> by Mindtool, Corporation (www.mindtool.com).
> > >>
> > >> An archive of the CFCDev list is available at
> > > www.mail-archive.com/[EMAIL PROTECTED]
> > >
> > > ----------------------------------------------------------
> > > You are subscribed to cfcdev. To unsubscribe, send an email to
> > > [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' in
> > the message
> > > of the email.
> > >
> > > CFCDev is run by CFCZone (www.cfczone.org) and supported
> > > by Mindtool, Corporation (www.mindtool.com).
> > >
> > > An archive of the CFCDev list is available at
> > > www.mail-archive.com/[EMAIL PROTECTED]
> > >
> >
> > ----------------------------------------------------------
> > You are subscribed to cfcdev. To unsubscribe, send an email
> > to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
> > in the message of the email.
> >
> > CFCDev is run by CFCZone (www.cfczone.org) and supported
> > by Mindtool, Corporation (www.mindtool.com).
> >
> > An archive of the CFCDev list is available at
> > www.mail-archive.com/[EMAIL PROTECTED]
> >
>
>
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email
> to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
> in the message of the email.
>
> CFCDev is run by CFCZone (www.cfczone.org) and supported
> by Mindtool, Corporation (www.mindtool.com).
>
> An archive of the CFCDev list is available at
www.mail-archive.com/[EMAIL PROTECTED]
>

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to