[symfony-users] Re: How to access sfWebRequest object from the model

2009-03-21 Thread Lee Bolding
Or... $_SERVER['REMOTE_ADDR'] It may look "dirty", but your models won't be coupled to Symfony ;) It should be marginally more efficient too - after all, at the end of the day that's exactly how Symfony is gonna get that information back to you. On 21 Mar 2009, at 09:29, michael.pie...@goog

[symfony-users] Re: How to access sfWebRequest object from the model

2009-03-21 Thread Fabian Lange
I would do neither! The is the model. It knows about its data, but id does not know where to get it from. It should not. No models should read data from outside themselves. It might be finde to do recalculation of own data, but where should it get the information from? This is exactly the problem y

[symfony-users] Re: How to access sfWebRequest object from the model

2009-03-21 Thread Alan Bem
Yep, coupling model with outside data is really, really bad idea. Let's look at Lee's example of using plain $_SERVER array. It works. It works almost everywhere... ALMOST. 1. What if U will decide to move models to another project with another framework? What if that framework import all outside d

[symfony-users] Re: How to access sfWebRequest object from the model

2009-03-21 Thread michael.pie...@googlemail.com
sfContext::getInstance()->getRequest() Michael On 21 Mrz., 03:00, Benjamin wrote: > Hello, > > In my user model I would like to capture the user's ip address for new > records in the user->save() event.  I am using symfony 1.2.  What is > the best way to access the sfWebRequest object from wit

[symfony-users] Re: How to access sfWebRequest object from the model

2009-03-21 Thread Alan Bem
On Sat, Mar 21, 2009 at 12:05 PM, Lee Bolding wrote: > > is it even possible to overwrite $_SERVER['REMOTE_ADDR']? I'll try it > later on. Of course - its a variable. I don't think ANYBODY would ever use a framework that did that - if > they did, they'd have far bigger problems than this ;) >

[symfony-users] Re: How to access sfWebRequest object from the model

2009-03-21 Thread Lee Bolding
is it even possible to overwrite $_SERVER['REMOTE_ADDR']? I'll try it later on. I don't think ANYBODY would ever use a framework that did that - if they did, they'd have far bigger problems than this ;) As for Quercus, it's not stable - again, you've got far bigger problems than just $_SER

[symfony-users] Re: How to access sfWebRequest object from the model

2009-03-21 Thread Fabian Lange
Some more ideas.. some from the more practical side: when you put it into save(): - what happens when you run a script to update the records which invokes save()? - what happens if an admin edits and save()s? - what happens if a save() is triggered by a second save() on a related object (have a

[symfony-users] Re: How to access sfWebRequest object from the model

2009-03-21 Thread Lee Bolding
On 21 Mar 2009, at 11:40, Alan Bem wrote: > On Sat, Mar 21, 2009 at 12:05 PM, Lee Bolding > wrote: > > is it even possible to overwrite $_SERVER['REMOTE_ADDR']? I'll try it > later on. > > Of course - its a variable. Yup, I tested it - you can. I never thought of that before. I always assu

[symfony-users] Re: How to access sfWebRequest object from the model

2009-03-21 Thread Alan Bem
On Sat, Mar 21, 2009 at 4:51 PM, Lee Bolding wrote: > > Yup, I tested it - you can. I never thought of that before. I always > assumed (hoped?) the Zend Engine would somehow make environment > variables read-only. > Let me quote a line from great movie "A Knight's Tale": "*(...) Pain*, *lots of

[symfony-users] Re: How to access sfWebRequest object from the model

2009-03-21 Thread Benjamin
There have been lots of great comments here and I have read all of them. Fabian, I was going to deal with a majority of the issues you mentioned by testing if a record was new or not. Based on what everyone is saying though it was wrong for me to place this in the model. I'll tell you guys what

[symfony-users] Re: How to access sfWebRequest object from the model

2009-03-21 Thread Alan Bem
On Sat, Mar 21, 2009 at 8:44 PM, Benjamin wrote: > 1. When a password is saved, the setPassword method of the User model > converts it into a hash. > 2. I will set the ip using the action. The setIp method will convert > it into an integer. I know there were some recommendations about > creat

[symfony-users] Re: How to access sfWebRequest object from the model

2009-03-21 Thread Lee Bolding
MySQL has built-in functionality for this with its inet_aton and inet_ntoa functions. I'm not entirely sure how you'd be able to use these from Doctrine or Propel though. PHP also has built-in ip2long and long2ip which achieve the same. I don't understand your push v's pull problem :-/ You