RE: Keeping unbindModel out of your controllers

2006-12-26 Thread Mariano Iglesias


Sure, no problem. I'll wait for your feedback.

-MI

---

Remember, smart coders answer ten questions for every question they ask. 
So be smart, be cool, and share your knowledge. 


BAKE ON!


-Mensaje original-
De: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] En nombre
de Mikee Freedom
Enviado el: Martes, 26 de Diciembre de 2006 03:31 a.m.
Para: cake-php@googlegroups.com
Asunto: Re: Keeping unbindModel out of your controllers

Apologies for not getting on to this sooner - chrissy and all!

Will get stuck in to it later today or tomorrow and let you know.
Thanks for taking the time out to really help me.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Keeping unbindModel out of your controllers

2006-12-25 Thread Mikee Freedom
 Diciembre de 2006 08:22 p.m.
Para: cake-php@googlegroups.com
Asunto: Re: Keeping unbindModel out of your controllers

Using the new method returns the same result unfortunately.

Is it how I've defined my associations maybe? Is that not the proper
definition for parent - child?






--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



RE: Keeping unbindModel out of your controllers

2006-12-19 Thread Mariano Iglesias
 Mikee Freedom
Enviado el: Lunes, 18 de Diciembre de 2006 08:22 p.m.
Para: cake-php@googlegroups.com
Asunto: Re: Keeping unbindModel out of your controllers

Using the new method returns the same result unfortunately.

Is it how I've defined my associations maybe? Is that not the proper
definition for parent - child?


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
Cake PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Keeping unbindModel out of your controllers

2006-12-18 Thread Mikee Freedom

hey Mariano,

Just as a heads up, I've been employing your expects method all over
the place with great results. Been spending way too much time updating
some old code but I just can't help myself.

One thing I noticed this morning, but haven't looked in to in any
great detail, is that when using the old method I run in to problems
if I have parent child relationship existing within the same Model.

e.g. Categories having child categories

On a particular page I would like to display all child categories with
an associated image, and all products of the category specified (by
id). I do not need the product list of the child categories at this
time.

// this model should grab everything so leave it as is
$this-{$this-modelClass}-expects(
array(
'EcomCategoryParent',
'EcomCategoryChild',
'EcomProduct',
'EcomImage'
)
);
// children we need the image of
$this-{$this-modelClass}-EcomCategoryChild-expects(
array(
'EcomImage'
)
);
// products we want the image of as well
$this-{$this-modelClass}-EcomProduct-expects(
array(
'EcomImage'
)
);
// images we want nothing of
$this-{$this-modelClass}-EcomImage-expects();

For some reason, this doesn't return any products for the category
being requested even though some do in fact exist.

Agin, I haven't had time to look in to it but thought I would let you
know. For the moment I'm going to work around it but I'm sure at some
stage (when the product list becomes extensive) I will need to find a
solution.

If I do I will let you know.

Thank you again for this great piece of code!

cheers,
mikee

On 17/12/06, Mikee Freedom [EMAIL PROTECTED] wrote:
 Beautiful!

 Thanks again mate,
 mikee

 On 17/12/06, Mariano Iglesias [EMAIL PROTECTED] wrote:
 
  Article got approved already.
 
  About your way to handle it: it makes sense, having sort of a versioning
  control. Pretty cool.
 
  -MI
 
  ---
 
  Remember, smart coders answer ten questions for every question they ask.
  So be smart, be cool, and share your knowledge.
 
  BAKE ON!
 
  -Mensaje original-
  De: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] En nombre
  de Claudio Poli
  Enviado el: Sábado, 16 de Diciembre de 2006 05:20 a.m.
  Para: cake-php@googlegroups.com
  Asunto: Re: Keeping unbindModel out of your controllers
 
  interesting enough, I'm facing the same problem in my app.
  I'm finishing a project where an user can submit an article, this
  article can have a state, like approved, rejected, deleted, draft, on
  hold.
  I've drawed a workflow, after much pulling my hair out, I ended up
  with this solution: when an user submit a new revision, admins gets
  an email and the edit automatically gets approved.
  this because if a user modify, is correct that the previous version
  is still online, and when admin approves the new, it flips on the old
  version.
  this require an intense database work, since we need to take care
  even of the tags (habtm).
  so I ended up with this solution to keep an online version, that a
  user can modify from two months after the creation date.
  bakery instead, I believe, will change the state of the article upon
  a revision, but if admins don't/won't approve the new version, the
  article isn't published anymore until a new revision.
  my solution require confidence with users that will submit an article
  of course, but for the sake of simplicity to me is the best choice
  for now, until I will implement a versioning system.
 
 
   
 


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
Cake PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



RE: Keeping unbindModel out of your controllers

2006-12-18 Thread Mariano Iglesias

Ok, couple of questions for you:

1. Are you using the new version of the code with old style version of
parameters (via array)? There were no bug fixes and new version (as I
haven't yet encountered bugs on previous version), but just so it is easy
for us to know what to debug.

2. How is your model relationship built?

3. Category - CategoryChild sounds like a great thing for findAllThreaded,
previously calling expects() to only let models you are interested be as
results, did you consider this? From my side I use this to build an n-depth
level tree of categories and I use expect not to obtain related data to each
category and works like a charm.

Let's try to see if we can nail it down. It's weird that you would get
unexpected results as to model unbinding since the code makes use of
unbindModel() to do the actual unbinding. If we can cover the above 3 points
and you still have problems we'll debug expects() to see which models are
actually getting unbinded.

And I agree, better get this resolved now than having to deal with it later.

-MI

---

Remember, smart coders answer ten questions for every question they ask. 
So be smart, be cool, and share your knowledge. 

BAKE ON!


-Mensaje original-
De: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] En nombre
de Mikee Freedom
Enviado el: Lunes, 18 de Diciembre de 2006 04:06 p.m.
Para: cake-php@googlegroups.com
Asunto: Re: Keeping unbindModel out of your controllers

One thing I noticed this morning, but haven't looked in to in any
great detail, is that when using the old method I run in to problems
if I have parent child relationship existing within the same Model.

e.g. Categories having child categories


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
Cake PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Keeping unbindModel out of your controllers

2006-12-18 Thread Mikee Freedom

spot on mate!

in answer to your questions:

1.
- new version of the code yes
- old method (of arrays) employed yes
- I will go about putting in the new style now to see if that has any
impact (sorry i didn't do this before)

2. model relationship is as follows:

/* belongs to */
/* tree relationship with itself */
var $hasOne = array(

'EcomCategoryParent' = array(

'className' = 'EcomCategory',
'foreignKey' = 'parent_id'

)

);

/* has many */
var $hasMany = array(

'EcomCategoryChild' = array(

'className' = 'EcomCategory',
'foreignKey' = 'parent_id'

)

);

/* has and belongs to many */
var $hasAndBelongsToMany = array(

'EcomProduct' = array(

'className' = 'EcomProduct',
'joinTable' = 'ecom_categories_products'

),
'EcomImage' = array(

'className' = 'EcomImage',
'joinTable' = 'ecom_categories_images'

)

);

3. you're absolutely right, findAllThreaded is gold for this purpose.
however, in this instance I require the following information

- path in tree to current category (for the purpose of bread crumbs)
- - currently I haven't figured out how to do this without calling
findAllThreaded from the very top

- information relating to the requested category
- - name, description, etc

- associated images of requested categories
- - however, I do not need associated images of any parent categories
(or categories above requested in tree)

- child categories
- - I only need one level down for this screen

- associated images of child categories

- products of requested category
- - and definitely not products of any other category as this will
become a real problem over time

now, all this is well and good., and since you've introduced me to
expects() i've been trying as much as possible to only request the
information i require. I can't figure out how to extract only the
information i require in this instance.

it seems that if i tell EcomCategoryParent to only expect Parents and
EcomCategoryChildren to only expect Images then that seems to indicate
to EcomCategory that it doesn't want products.

It could be down to my use of the old method.

Will try the new and let you know.

Thanks for your help on this one,
mikee

On 19/12/06, Mariano Iglesias [EMAIL PROTECTED] wrote:

 Ok, couple of questions for you:

 1. Are you using the new version of the code with old style version of
 parameters (via array)? There were no bug fixes and new version (as I
 haven't yet encountered bugs on previous version), but just so it is easy
 for us to know what to debug.

 2. How is your model relationship built?

 3. Category - CategoryChild sounds like a great thing for findAllThreaded,
 previously calling expects() to only let models you are interested be as
 results, did you consider this? From my side I use this to build an n-depth
 level tree of categories and I use expect not to obtain related data to each
 category and works like a charm.

 Let's try to see if we can nail it down. It's weird that you would get
 unexpected results as to model unbinding since the code makes use of
 unbindModel() to do the actual unbinding. If we can cover the above 3 points
 and you still have problems we'll debug expects() to see which models are
 actually getting unbinded.

 And I agree, better get this resolved now than having to deal with it later.

 -MI

 ---

 Remember, smart coders answer ten questions for every question they ask.
 So be smart, be cool, and share your knowledge.

 BAKE ON!


 -Mensaje original-
 De: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] En nombre
 de Mikee Freedom
 Enviado el: Lunes, 18 de Diciembre de 2006 04:06 p.m.
 Para: cake-php@googlegroups.com
 Asunto: Re: Keeping unbindModel out of your controllers

 One thing I noticed this morning, but haven't looked in to in any
 great detail, is that when using the old method I run in to problems
 if I have parent child relationship existing within the same Model.

 e.g. Categories having child categories


 


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
Cake PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



RE: Keeping unbindModel out of your controllers

2006-12-16 Thread Mariano Iglesias

Oh, yes you are right. It seems that after editing an article the bakery
puts it back on the approval queue. It doesn't seem like a bug to me, it
makes sense (otherwise one could get published a good article, and then edit
it and put spam or whatever.)

So we've just gotta be patient again :)

-MI

---

Remember, smart coders answer ten questions for every question they ask. 
So be smart, be cool, and share your knowledge. 

BAKE ON!


-Mensaje original-
De: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] En nombre
de Claudio Poli
Enviado el: Sábado, 16 de Diciembre de 2006 04:52 a.m.
Para: cake-php@googlegroups.com
Asunto: Re: Keeping unbindModel out of your controllers

On 16/dic/06, at 08:35, Mariano Iglesias wrote:

 http://bakery.cakephp.org/articles/view/185

btw bakery says invalid article..



--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
Cake PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Keeping unbindModel out of your controllers

2006-12-16 Thread Claudio Poli

On 16/dic/06, at 09:04, Mariano Iglesias wrote:


 Oh, yes you are right. It seems that after editing an article the  
 bakery
 puts it back on the approval queue. It doesn't seem like a bug to  
 me, it
 makes sense (otherwise one could get published a good article, and  
 then edit
 it and put spam or whatever.)

 So we've just gotta be patient again :)

interesting enough, I'm facing the same problem in my app.
I'm finishing a project where an user can submit an article, this  
article can have a state, like approved, rejected, deleted, draft, on  
hold.
I've drawed a workflow, after much pulling my hair out, I ended up  
with this solution: when an user submit a new revision, admins gets  
an email and the edit automatically gets approved.
this because if a user modify, is correct that the previous version  
is still online, and when admin approves the new, it flips on the old  
version.
this require an intense database work, since we need to take care  
even of the tags (habtm).
so I ended up with this solution to keep an online version, that a  
user can modify from two months after the creation date.
bakery instead, I believe, will change the state of the article upon  
a revision, but if admins don't/won't approve the new version, the  
article isn't published anymore until a new revision.
my solution require confidence with users that will submit an article  
of course, but for the sake of simplicity to me is the best choice  
for now, until I will implement a versioning system.

--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
Cake PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



RE: Keeping unbindModel out of your controllers

2006-12-16 Thread Mariano Iglesias

Article got approved already.

About your way to handle it: it makes sense, having sort of a versioning
control. Pretty cool.

-MI

---

Remember, smart coders answer ten questions for every question they ask. 
So be smart, be cool, and share your knowledge. 

BAKE ON!

-Mensaje original-
De: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] En nombre
de Claudio Poli
Enviado el: Sábado, 16 de Diciembre de 2006 05:20 a.m.
Para: cake-php@googlegroups.com
Asunto: Re: Keeping unbindModel out of your controllers

interesting enough, I'm facing the same problem in my app.
I'm finishing a project where an user can submit an article, this  
article can have a state, like approved, rejected, deleted, draft, on  
hold.
I've drawed a workflow, after much pulling my hair out, I ended up  
with this solution: when an user submit a new revision, admins gets  
an email and the edit automatically gets approved.
this because if a user modify, is correct that the previous version  
is still online, and when admin approves the new, it flips on the old  
version.
this require an intense database work, since we need to take care  
even of the tags (habtm).
so I ended up with this solution to keep an online version, that a  
user can modify from two months after the creation date.
bakery instead, I believe, will change the state of the article upon  
a revision, but if admins don't/won't approve the new version, the  
article isn't published anymore until a new revision.
my solution require confidence with users that will submit an article  
of course, but for the sake of simplicity to me is the best choice  
for now, until I will implement a versioning system.


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
Cake PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Keeping unbindModel out of your controllers

2006-12-16 Thread Mikee Freedom

Beautiful!

Thanks again mate,
mikee

On 17/12/06, Mariano Iglesias [EMAIL PROTECTED] wrote:

 Article got approved already.

 About your way to handle it: it makes sense, having sort of a versioning
 control. Pretty cool.

 -MI

 ---

 Remember, smart coders answer ten questions for every question they ask.
 So be smart, be cool, and share your knowledge.

 BAKE ON!

 -Mensaje original-
 De: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] En nombre
 de Claudio Poli
 Enviado el: Sábado, 16 de Diciembre de 2006 05:20 a.m.
 Para: cake-php@googlegroups.com
 Asunto: Re: Keeping unbindModel out of your controllers

 interesting enough, I'm facing the same problem in my app.
 I'm finishing a project where an user can submit an article, this
 article can have a state, like approved, rejected, deleted, draft, on
 hold.
 I've drawed a workflow, after much pulling my hair out, I ended up
 with this solution: when an user submit a new revision, admins gets
 an email and the edit automatically gets approved.
 this because if a user modify, is correct that the previous version
 is still online, and when admin approves the new, it flips on the old
 version.
 this require an intense database work, since we need to take care
 even of the tags (habtm).
 so I ended up with this solution to keep an online version, that a
 user can modify from two months after the creation date.
 bakery instead, I believe, will change the state of the article upon
 a revision, but if admins don't/won't approve the new version, the
 article isn't published anymore until a new revision.
 my solution require confidence with users that will submit an article
 of course, but for the sake of simplicity to me is the best choice
 for now, until I will implement a versioning system.


 


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
Cake PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



RE: Keeping unbindModel out of your controllers

2006-12-15 Thread Mariano Iglesias

Thanks mate. I just improved the code even further. Updating your code with
the new version doesn't require you to do any modifications to your existing
expects() call, so it is upgrade safe. The article:

http://bakery.cakephp.org/articles/view/185

Contains the code update and explanation (look for section titled Making
multiple expects() in one call.

As a short preview, when we used to do something like:

$this-Post-Author-expects(); 
$this-Post-Category-expects(); 
$this-Post-PostDetail-expects(array('PostExtendedDetail',
'PostAttachment'));

We can now do in just one call:

$this-Post-expects('Author.Author', 'Category.Category',
'PostDetail.PostExtendedDetail', 'PostDetail.PostAttachment'); 

Another example, version 1 form:

$this-Title-expects(array('Story', 'Post'));  
$this-Title-Post-expects(array('User'));

New form:

$this-Title-expects('Story', 'Post.User');

Again, your old way of calling (through arrays) WILL STILL work. 

I've just made the change since I wanted to clean up my controller code even
further. So those two or three logical lines can turn into one logical
line ;)

-MI

---

Remember, smart coders answer ten questions for every question they ask. 
So be smart, be cool, and share your knowledge. 

BAKE ON!

-Mensaje original-
De: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] En nombre
de Mikee Freedom
Enviado el: Viernes, 15 de Diciembre de 2006 03:43 a.m.
Para: cake-php@googlegroups.com
Asunto: Re: Keeping unbindModel out of your controllers

it has to be said - you rock!

I was just at the point that I thought some of my controllers looked
extremely unwieldy due to the bindModel and unbindModel calls I was
making.

Now with 2 or 3 logical lines everything stays nice and clean and my
DB requests are always the size they need to be.



--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
Cake PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Keeping unbindModel out of your controllers

2006-12-15 Thread Claudio Poli

On 16/dic/06, at 08:35, Mariano Iglesias wrote:

 [snip]
 Again, your old way of calling (through arrays) WILL STILL work.

 I've just made the change since I wanted to clean up my controller  
 code even
 further. So those two or three logical lines can turn into one  
 logical
 line ;)

ok, I'm losing my senses again ;)

thanks for your work.

--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
Cake PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Keeping unbindModel out of your controllers

2006-12-15 Thread Claudio Poli


On 16/dic/06, at 08:35, Mariano Iglesias wrote:

 http://bakery.cakephp.org/articles/view/185

btw bakery says invalid article..

--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
Cake PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



RE: Keeping unbindModel out of your controllers

2006-12-14 Thread Mariano Iglesias

Hehe... I'm glad that it's useful for you guys.

-MI

---

Remember, smart coders answer ten questions for every question they ask. 
So be smart, be cool, and share your knowledge. 

BAKE ON!

-Mensaje original-
De: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] En nombre
de Claudio Poli ?
Enviado el: Jueves, 14 de Diciembre de 2006 04:10 a.m.
Para: Cake PHP
Asunto: Re: Keeping unbindModel out of your controllers

works so well that I've lost my senses.

thanks Mariano


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
Cake PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Keeping unbindModel out of your controllers

2006-12-14 Thread Mikee Freedom

it has to be said - you rock!

I was just at the point that I thought some of my controllers looked
extremely unwieldy due to the bindModel and unbindModel calls I was
making.

Now with 2 or 3 logical lines everything stays nice and clean and my
DB requests are always the size they need to be.

Thanks again mate,
mikee

On 14/12/06, Mariano Iglesias [EMAIL PROTECTED] wrote:

 Hehe... I'm glad that it's useful for you guys.

 -MI

 ---

 Remember, smart coders answer ten questions for every question they ask.
 So be smart, be cool, and share your knowledge.

 BAKE ON!

 -Mensaje original-
 De: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] En nombre
 de Claudio Poli ?
 Enviado el: Jueves, 14 de Diciembre de 2006 04:10 a.m.
 Para: Cake PHP
 Asunto: Re: Keeping unbindModel out of your controllers

 works so well that I've lost my senses.

 thanks Mariano


 


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
Cake PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Keeping unbindModel out of your controllers

2006-12-13 Thread Claudio Poli 

works so well that I've lost my senses.

thanks Mariano


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
Cake PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---