Re: Behaviours - Session data
What happens when you want a process to be accessible from command line, or a cron job? Curious. I've never really given thought to this. I'm sure if it ever came to it though, I'd modify the behavior in some manner to let me tell it there is no session. Ya 99% of my cart code is in components. In one case though I had a user upload a custom image to attach to the item, so I had to put some session code in the model so the image could keep track of it's id. Best practice, worst practice... who knows, and who cares? It got the job done, it works and that is that. Sexy code doesn't pay the bills. -Rob On Nov 21, 11:07 pm, Grant Cox [EMAIL PROTECTED] wrote: Perhaps I worded my first response too harshly - as there are certainly cases where it is far easier to access the session directly than to have a more elegant solution. I too have a similar model behaviour (created_by, modified_by), however this is a single $_SESSION access - literally one line, out of the entire application. I'd be interested to hear what shopping cart functionality you used in a model - I've always implemented with a component only. So yes, it can be easier. But still, models should not be tied to the session, and *I think* doing so is a hack. What happens when you want a process to be accessible from command line, or a cron job? On Nov 22, 3:01 pm, rtconner [EMAIL PROTECTED] wrote: Ya Grant not to argue with you, but if you are going to make a statement like that, you make me think you have not done much cake programming. (Though for how long you've been around I'll assume otherwise) I need data from the session in the models all the time. It's usually a modified_by or created_by type of thing. Sometimes its other things, like enclosing shopping cart abilities into a model and component. Cake is meant to make tasks simple and isolated so you don't have to repeat yourself. If you can't enclose this type of thing into a behavior, then what good is cake? Not accessing this data from within a model really defeats the DRY principal. On Nov 21, 3:54 pm, Grant Cox [EMAIL PROTECTED] wrote: Cake does not provide a method, as you should not be accessing the session from any model / behaviour. Sometimes it is just much easier to do so though, so you can still access $_SESSION directly. But you really should reconsider whether you have to access the session in your model / behaviour - it may indicate an overall problem with your application structure. On Nov 21, 11:46 pm, villas [EMAIL PROTECTED] wrote: Cake 1.2 -- How can I access session data from inside a 'behaviour' file? TIA --~--~-~--~~~---~--~~ 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: Behaviours - Session data
Cake does not provide a method, as you should not be accessing the session from any model / behaviour. Sometimes it is just much easier to do so though, so you can still access $_SESSION directly. But you really should reconsider whether you have to access the session in your model / behaviour - it may indicate an overall problem with your application structure. On Nov 21, 11:46 pm, villas [EMAIL PROTECTED] wrote: Cake 1.2 -- How can I access session data from inside a 'behaviour' file? TIA --~--~-~--~~~---~--~~ 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: Behaviours - Session data
Hi, I just thought of a problem I have, and maybe it's a case where model would need session data: a model behaviour to change table columns according to the choosen language. How that language could be stored ? How model could access it ? thanks spark On Nov 21, 2007 8:54 PM, Grant Cox [EMAIL PROTECTED] wrote: Cake does not provide a method, as you should not be accessing the session from any model / behaviour. Sometimes it is just much easier to do so though, so you can still access $_SESSION directly. But you really should reconsider whether you have to access the session in your model / behaviour - it may indicate an overall problem with your application structure. On Nov 21, 11:46 pm, villas [EMAIL PROTECTED] wrote: Cake 1.2 -- How can I access session data from inside a 'behaviour' file? TIA -- [livesets] http://djspark.com.br/ [web] http://sydi.net [filmes] http://melhoresfilmes.com.br --~--~-~--~~~---~--~~ 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: Behaviours - Session data
Ya Grant not to argue with you, but if you are going to make a statement like that, you make me think you have not done much cake programming. (Though for how long you've been around I'll assume otherwise) I need data from the session in the models all the time. It's usually a modified_by or created_by type of thing. Sometimes its other things, like enclosing shopping cart abilities into a model and component. Cake is meant to make tasks simple and isolated so you don't have to repeat yourself. If you can't enclose this type of thing into a behavior, then what good is cake? Not accessing this data from within a model really defeats the DRY principal. On Nov 21, 3:54 pm, Grant Cox [EMAIL PROTECTED] wrote: Cake does not provide a method, as you should not be accessing the session from any model / behaviour. Sometimes it is just much easier to do so though, so you can still access $_SESSION directly. But you really should reconsider whether you have to access the session in your model / behaviour - it may indicate an overall problem with your application structure. On Nov 21, 11:46 pm, villas [EMAIL PROTECTED] wrote: Cake 1.2 -- How can I access session data from inside a 'behaviour' file? TIA --~--~-~--~~~---~--~~ 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: Behaviours - Session data
@rtconner: Grant is right and you don't know what you're talking about. Stop acting like a punk. $this-Model-set('member', $this-Session-read('Member.name')); It's not rocket surgery. On Nov 22, 12:01 am, rtconner [EMAIL PROTECTED] wrote: Ya Grant not to argue with you, but if you are going to make a statement like that, you make me think you have not done much cake programming. (Though for how long you've been around I'll assume otherwise) I need data from the session in the models all the time. It's usually a modified_by or created_by type of thing. Sometimes its other things, like enclosing shopping cart abilities into a model and component. Cake is meant to make tasks simple and isolated so you don't have to repeat yourself. If you can't enclose this type of thing into a behavior, then what good is cake? Not accessing this data from within a model really defeats the DRY principal. On Nov 21, 3:54 pm, Grant Cox [EMAIL PROTECTED] wrote: Cake does not provide a method, as you should not be accessing the session from any model / behaviour. Sometimes it is just much easier to do so though, so you can still access $_SESSION directly. But you really should reconsider whether you have to access the session in your model / behaviour - it may indicate an overall problem with your application structure. On Nov 21, 11:46 pm, villas [EMAIL PROTECTED] wrote: Cake 1.2 -- How can I access session data from inside a 'behaviour' file? TIA --~--~-~--~~~---~--~~ 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: Behaviours - Session data
And that nate's response came in 20 minutes before mine showed how long I sat here thinking about it, heh. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---