CakePHP beforeSave() gotcha: need to set $this->__exists to true if setting a primary key

I added an update to CakePHP Book: beforeSave()

Also, if you add a primary key which would turn an “insert” into an “update” within beforeSave() you’ll need to set $this->__exists = true;… the call to $this->exists(); happens in model.php before the callback to beforeSave().

function beforeSave() {
	if (!isset($this->data[$this->name]['id']) && isset($this->data[$this->name]['unique_field'])) {
		$found = $this->find("first",array(
				"recursive" => -1,
				"fields" => array("id"),
				"conditions" => array("unique_field" => $this->data[$this->name]['unique_field'])));
		if (!empty($found) && isset($found[$this->name]['id'])) {
			$this->id = $this->data[$this->name]['id'] = $found[$this->name]['id'];
			$this->__exists = true;
		}
	}
	return parent::beforeSave();
}

That’s been confusing me a bit recently – setting the ID of a row within beforesave() should change the save to an update, but it was trying to insert with a specified ID and thus, failing… glad to have a simple solution that makes sense… hope that helps someone else…

Google Profiles now with content

Alan’s Google Profile, now updated with Buzz activity, searchable, and pulling content from various feeds, including flickr, facebook, twitter, etc…

If you don’t see this as “competition” for Facebook (et. al.) then you’re not seeing the same thing I am.

I personally love it, esp. the publicly searchable aspects and the integration  into the gmail interface but I might stop using it if other people don’t or if it can’t work two-way with facebook….  (if I have to post in facebook for it to show up both places, guess what… I’ll just use facebook)

Oliver is born, go and tell it on the mountain

Most of you have heard from the grapevine or facebook (this generation’s grapevine) that our son, Oliver Jackson Blount, was born on 2010-02-02 @ 14:35 EST. He was 9 pounds 15 ounces and 23 inches (they measured twice to be sure).

We had a home birth with 2 midwives and an apprentice, a doula, Anita’s mom (former NICU nurse) and sister Virginia (new nurse) in attendance… of yeah, and me. The decision to have a home birth was one we took very seriously and subsequently are very happy with; it being unusual is often the topic of conversation… but I can summarize with the following: We had a normal and healthy fetus inside a normal and healthy mom, everything looking like it would progress as “low risk” we choose to stay at home with the support of professionals vs. being put through the standard process mill at a hospital. It was great.

Anita apparently figured out all this birthing stuff the first time, because she was in charge for this one. She had some intense but intermittent early labor the day before. It died out in the afternoon and came back at night time, persistent but spaced far enough apart Anita could sleep for 30-50 minutes between contractions. In the morning we coordinated passing off Poppy to one of the volunteers who would take her, packed her bags and handed her off right about 9:00am. Seriously at 9:05 Anita switched from “early” to “active” labor and things picked up. (more reading on the stages of labor) Our Doula arrived shortly thereafter and picked up on a speedy progression and encouraged us to get the midwives here. We weren’t sure, since Anita was still talking between contractions and smiling and whatnot, but she continued to progress and we realized that things were in fact going fast. She basically dampened things down until the midwives arrived at about 12:30pm. Within minutes (again), poof, she was in transition… She pushed from about 1:15 to 2:35 when Oliver was born.

It’s one thing to have done research and internalized that labor is a natural thing for women to do as part of being human, and something wonderful to see someone go through the whole hard, messy, awe-inspiring process with such strength and grace. She will argue the point, I’m sure, but she was centered, prepared, and fantastic.

Whoever said women were the weaker sex had obviously never been to a child birth.

And now, the scary part…

Oliver was actually pretty stuck with shoulder dystocia and the midwives had to literally push him in a bit and pull out his arms so that he could come out (big baby? yeah, no doubt). He was pretty purple due to the process, but his heart rate stayed good. The midwives gave him a couple of breaths and we all (hopped up on adrenaline) rubbed on him and talked to him. We would have been more afraid if we hadn’t had this same thing happen to a friend of ours’ baby (now one of Poppy’s 1.5 yr old friends). He started breathing again and regained color well. Talking about it now I can be calm and explanatory, but it was harrowing for us to go through… the midwives said it isn’t common, but isn’t too uncommon either. Keeping the umbilical attached for a while helps assure backup support for a baby who isn’t breathing fast enough (and they had oxygen if needed, likewise we were ready to travel to a hospital should we needed to).

Once the first couple minutes of terrifying excitement had happened, Oliver was on Anita’s chest and we watched and talked and touched and processed. We finally got to look at him and he was very different than Poppy as a newborn. He has freckles and hair, blonde and perhaps a half inch long. He was confirmed a boy, and was certainly bigger than Poppy. He’s got the same monkey toes and dexterous fingers, same shar-pei-like rolls and folds in his skin, and somewhat similar features… He attempted nursing within minutes and in less than an hour he had latched on pretty well.

The midwives perform many of the same post-birth tests and procedures, so he got bended and prodded and whatnot… everything checks out on the “100% good” scale with no reservations.

We all hung around and talked and processed a bit more, and started sending out some notifications and made a few calls (though we were a bit remiss on that front, sorry to any who were missed). Finally Poppy came home and met her brother Oliver, whom she had been telling for weeks to “come out”. She was absolutely perfect, excited and perhaps not gentle enough, but for a 2-year-old she was just perfect. She held him on her lap, on one of our laps, and held his hand… she looks so big next to him… She is.

The last 24 hour has played out as you might hope for… Poppy went to school in the morning and help Oliver some before her naptime (as well as some special “Poppy” time). Several visitors in the evening, including one of Poppy’s 2yr old friends. People brought us food both nights [THANK YOU] and we are really all doing quite well. Tomorrow is just us, which we are a bit apprehensive about, but we’ve gotta figure out how to handle two kids sooner or later…. scratch that, sooner it is.

Aside from the scary first minute there were no problems throughout the whole process and there continue not to be. (Yay!)

More on little/big Ollie: He’s still good size 9# 5oz at his 24hr checkup. One of the midwives said to Anita “congratulations, you just gave birth to a toddler” – indeed sometimes when you look he doesn’t seem all that much smaller than Poppy. On the other hand, he is… All of his skin is still krinkly as if he’d been in the bath for way too long (like 10 months) and whisper soft. He has a lot of baby rashy skin like Poppy had, but the freckles are different. He also had a bit of bruising on the face, but I don’t think I notice it (just reporting what others say). He stretched out quickly, instead of staying all curled up. The funniest thing is how vocal he is. He snuffles and snorts and grunts pretty loudly and not infrequently. Largely it’s rooting, but no matter, it’s hilarious. His cry is cute, like all newborns I suppose, but it can be quite loud and high-pitched at times… He’s opening his eyes when awake and looking around some, though very uncoordinated. He also tries to lift up his head and even using his arms to lift off of one’s chest while holding him vertically… Impressive, even if mostly unsuccessful.

On a reflective note, there’s something slightly sad about life in that we have to compare any experience to others and can not just hold on to it for it’s own sake. I’m constantly comparing myself and my thoughts/actions/etc in this birth to those of Poppy’s. I’m not nearly as tired since ~5.5 hours is a much shorter labor than 26 hours. We are at home, surrounded by friends and family, and (drumroll) we’ve had a kid before. He’s new and wonderful and perfect, but at the same time he “checks out” and fits into patterns we’ve already experienced. I admit I was disappointed to not have felt more “paradigm-shifted”… perhaps I was still a bit shell-shocked. Perhaps I still am.

Regardless, our paradigm has certainly shifted, whether I felt it in a gush or incrementally… We now parent two, and already we juggle who to put down, who to diaper, and what boundaries fit. Perhaps most importantly, we have to figure out who to give attention to, when to have special “alone” time and how wefit together as a family… Perfectly well, I think… Amazing how much difference one more makes and how much more “full” the word family feels in my mind.

Photos
My Favorites:
Videos
You can see Poppy coming home on Ollie’s birthday to meet him for the first time: http://www.flickr.com/photos/zeroasterisk/4326109383
You can see some of Oliver’s facial expressions and a few noises: http://www.flickr.com/photos/zeroasterisk/4328419329
(more coming)
Funniest Quote:
Poppy is trying to figure out what she has control over and loves repetivie games… especially when she can say “no”… so often we gamesay something to her like “Hello Poppy” and she will counter: “Papa no, Hello Poppy” mirroring our inflection…
When Anita was Laboring in the morning, before poppy left, she moaned and Poppy said: “Mama no, mmmoooohhhhhhhhh”… A few minutes later Anita said “oh my god” and Poppy jumped right in with: “Mama no, oh my god” — of course this is during a contraction so a double-whammy for poor Anita because we couldn’t help but laugh.

Google Apps removes support for IE6

http://googleenterprise.blogspot.com/2010/01/modern-browsers-for-modern-applications.html

Many other companies have already stopped supporting older browsers like Internet Explorer 6.0 as well as browsers that are not supported by their own manufacturers. We’re also going to begin phasing out our support, starting with Google Docs and Google Sites. As a result you may find that from March 1 key functionality within these products — as well as new Docs and Sites features — won’t work properly in older browsers.

2010 is going to be a great year for Google Apps and we want to ensure that everyone can make the most of what we are developing. Please take the time to switch your organization to the most up-to-date browsers available.

I’m hoping this will be the killing stroke to a browser which has single-handedly caused me more frustration than any other piece of software, ever.