[comp.sys.mac.programmer] Publish & Subscribe

peirce@outpost.UUCP (Michael Peirce) (06/20/91)

I've been adding Publish & Subscibe capabilities to a program I am
working on.  For the most part all is working well.

My problem is that when I write out a published edition, I don't 
produce the automatic update I'd expect.  The data is out there - if 
I do a "Get Edition Now" from the subscribers they get the new edition
data.

When I publish an edition from another program, the expected read
AppleEvent shows up, but not when I update an edition.

Is there a "trick" to getting this behavior to work?  Might there
be some flag I need to set or additional call to make?  

Here's my write edition routine.  It's pretty much lifted from the
Edition Manager example from the System 7 CD-ROM.


void DoWriteEdition(FileRecHndl frHndl)
{
	OSErr				stat;
	EditionRefNum		eRefNum;
	Handle				h;

		
	 stat = OpenNewEdition((*frHndl)->doc.OutSection, 
	 			docCreator, &(**frHndl).fileState.fss, &eRefNum);
	
	if (stat != noErr) {
		DebugStr("\p OpenNewEdition");
		return;
	}
	
	h = (Handle) (*frHndl)->doc.resultPictH;
	HLock(h);
    stat = WriteEdition(eRefNum, 'PICT', *h, GetHandleSize(h);
	HUnlock(h);
	
	if (stat != noErr) DebugStr("\p WriteEdition error");
	
	if (stat == noErr) {
		stat = CloseEdition(eRefNum, true);
	} else {
		stat = CloseEdition(eRefNum, false);
	}
}

Any ideas would be appreciated.  Thanks.

--  Michael Peirce         --   outpost!peirce@claris.com
--  Peirce Software        --   Suite 301, 719 Hibiscus Place
--  Macintosh Programming  --   San Jose, California 95117
--           & Consulting  --   (408) 244-6554, AppleLink: PEIRCE

smoke@well.sf.ca.us (Nicholas Jackiw) (06/25/91)

In article <0B01FFFB.ijva0b@outpost.UUCP> peirce@outpost.UUCP (Michael Peirce) writes:
>
>My problem is that when I write out a published edition, I don't 
>produce the automatic update I'd expect.  The data is out there - if 
>I do a "Get Edition Now" from the subscribers they get the new edition
>data.
>Any ideas would be appreciated.  Thanks.

Are you updating the mdDate of the section record before writing the
edition data?  If not, the Edition Manager package will see that the
newly written edition doesn't supercede the previously written one
(both dates are the same), and not send off update events.  Why it
bothers to update the file in this case is beyond me--in one case,
it seems to believe you're making significant changes; in the other,
it refuses.  At any rate, try sticking a

  GetDateTime(modifiedNow);
  theEdition.SectionH^^.mdDate := modifiedNow;

before you OpenNewEdition(), and see if this changes anything.  If so,
fix the bugs in your edition time-stamping.  (Or implement edition
time-stamping, if you've overlooked it.)

Of course, none of this explains why it sometimes takes the Edition
Manager 30 or 40 seconds to send out SectionReads when there are only
two applications, both idle, open on an fx.  Some parts of System 7
are like having a Mac Plus again...






-- 
                              --- * ---
Nick Jackiw                  Smoke@well.sf.ca.us   | Jackiw@cs.swarthmore.edu
Key Curriculum Press, Inc.   Applelink:KEY.EDUSOFT | (415) 548-2304
                              --- * ---

peirce@outpost.UUCP (Michael Peirce) (06/26/91)

In article <25648@well.sf.ca.us>, smoke@well.sf.ca.us (Nicholas Jackiw) writes:
> In article <0B01FFFB.ijva0b@outpost.UUCP> peirce@outpost.UUCP (Michael Peirce) writes:
> >
> >My problem is that when I write out a published edition, I don't 
> >produce the automatic update I'd expect.  The data is out there - if 
> >I do a "Get Edition Now" from the subscribers they get the new edition
> >data.
> >Any ideas would be appreciated.  Thanks.
> 
> Are you updating the mdDate of the section record before writing the
> edition data?  If not, the Edition Manager package will see that the
> newly written edition doesn't supercede the previously written one
> (both dates are the same), and not send off update events.  Why it
> bothers to update the file in this case is beyond me--in one case,
> it seems to believe you're making significant changes; in the other,
> it refuses.  At any rate, try sticking a
> 
>   GetDateTime(modifiedNow);
>   theEdition.SectionH^^.mdDate := modifiedNow;
> 
> before you OpenNewEdition(), and see if this changes anything.  If so,
> fix the bugs in your edition time-stamping.  (Or implement edition
> time-stamping, if you've overlooked it.)

That's it!  Thanks!  

I didn't notice anything about having to set the modification date 
in IM VI.  Once I put this in it all works like a charm.

-- michael, slowly learning all this new System 7 stuff...

--  Michael Peirce         --   outpost!peirce@claris.com
--  Peirce Software        --   Suite 301, 719 Hibiscus Place
--  Macintosh Programming  --   San Jose, California 95117
--           & Consulting  --   (408) 244-6554, AppleLink: PEIRCE