Just come across this problem. What's the best way to test if the model
class is being called by the cli or not?
Cheers,
Tom
Frank Stelzer wrote:
> Did you check, if you are using sfContext in your child model classes
> on your own?
>
> Something like this here would break your task:
>
> public function save(PropelPDO $con = null)
> {
> // accessing sfContext here will break task
> sfContext::getInstance()->getLogger()->blah();
>
> return parent::save($con);
> }
>
> - Frank
> Am 17.05.2009 um 06:41 schrieb nick:
>
>>
>> I'm using Symfony 1.2.7. I'm using Propel as the ORM. I would like to
>> be able to run this command:
>>
>> symfony propel:build-all-load
>>
>> I try to run this and I get the error:
>>
>> The "default" context does not exist.
>>
>> I look around on Google and there are dozens of mentions of this
>> error, such as this discussion on the forum:
>>
>> http://forum.symfony-project.org/index.php/t/15101/
>>
>> Apparently the problem is the sfContext()
>>
>> Here, Jonathon Wage suggests not using the current context in model
>> classes:
>>
>> http://groups.google.com/group/symfony-devs/msg/52ffa70b40d5f44d
>>
>> Here Fabien Potencier responds to an old post about this problem, and
>> he writes:
>>
>> "One of the main goal of the configuration refactoring was to be able
>> to use all symfony tools without initializing a sfContext object."
>>
>> However, I face a problem. sfContext is used in several plugins, and
>> in dozens of places in the code. It shows up in the base classes
>> generated by Propel. If I were to try to comment out the line that is
>> cause the trouble, I would hardly know where to start. Consider how
>> many times this appears. Suppose I change directory so that I'm in the
>> symfony project directory, and then I run this command:
>>
>> grep -R sfContext *
>>
>> I get:
>>
>>
>>
>> apps/frontend/lib/myUser.class.php: sfContext::getInstance()-
>>> getConfiguration()->loadHelpers('Privacy');
>> lib/model/om/BaseApartmentInterestredRentPeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentRentPeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentCategoryPeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentDraftAnswerPeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentUserTypePeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentWaitListPeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentAffiliateInPeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentUserPeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentPrizeTypePeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentAnswerTypePeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentUserProfileImagePeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentAuditTrailPeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentAnswerStatusPeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentPasswordResetPeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentPrivacySettingPeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentAffiliateOutPeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentPaymentTypePeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentPriorityPeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentPaymentStatusPeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentUserStatusPeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentInterestredAnswerPeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentFeaturedRentPeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentFeatureTypePeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentFeatureStatusPeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentAnswerPeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentVotesPeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentInterestredUserPeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentRentTypePeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentPrivacyEntityPeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentRentStatusPeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentCategoryImagePeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentImagePeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentDraftRentPeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentUserTransactionPeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> lib/model/om/BaseApartmentUserTransactionTypePeer.php: $request
>> = sfContext::getInstance()->getRequest();
>> lib/model/ApartmentRent.php: $this->setPaymentInfo
>> (sfContext::getInstance()->getUser()->getGuardUser()->getApartmentUser
>> ()->getEmail());
>>
>> lib/form/ApartmentRentForm.class.php: $object->setUserId
>> (sfContext::getInstance()->getUser()->getGuardUser()->getApartmentUser
>> ()->getId());
>> lib/form/ApartmentAnswerForm.class.php: $object->setUserId
>> (sfContext::getInstance()->getUser()->getGuardUser()->getApartmentUser
>> ()->getId());
>>
>> plugins/sfGuardPlugin/lib/model/om/
>> BasesfGuardUserPermissionPeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> plugins/sfGuardPlugin/lib/model/om/
>> BasesfGuardRememberKeyPeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> plugins/sfGuardPlugin/lib/model/om/
>> BasesfGuardGroupPermissionPeer.php: $request =
>> sfContext::getInstance()->getRequest();
>> plugins/sfGuardPlugin/lib/model/om/
>> BasesfGuardPermissionPeer.php: $request =
>> sfContext::getInstance
>> ()->getRequest();
>> plugins/sfGuardPlugin/lib/model/om/
>> BasesfGuardUserGroupPeer.php: $request = sfContext::getInstance
>> ()->getRequest();
>> plugins/sfGuardPlugin/lib/model/om/BasesfGuardGroupPeer.php:
>> $request = sfContext::getInstance()->getRequest();
>> plugins/sfGuardPlugin/lib/model/om/BasesfGuardUserPeer.php:
>> $request = sfContext::getInstance()->getRequest();
>>
>> plugins/sfGuardPlugin/lib/user/sfGuardSecurityUser.class.php:
>> sfContext::getInstance()->getResponse()->setCookie($remember_cookie,
>> $key, time() + $expiration_age);
>> plugins/sfGuardPlugin/lib/user/sfGuardSecurityUser.class.php:
>> sfContext::getInstance()->getResponse()->setCookie($remember_cookie,
>> '', time() - $expiration_age);
>>
>> plugins/sfPropelActAsCommentableBehaviorPlugin/lib/model/om/
>> BasesfCommentPeer.php: $request = sfContext::getInstance()-
>>> getRequest();
>> plugins/sfPropelActAsCommentableBehaviorPlugin/lib/form/
>> sfCommentingForm.class.php: $config = sfContext::getInstance()-
>>> getUser()->isAuthenticated() ? $config['user'] : $config
>> ['anonymous'];
>> plugins/sfPropelActAsCommentableBehaviorPlugin/lib/form/
>> sfCommentingForm.class.php: if (sfContext::getInstance()-
>>> getUser()-
>>> isAuthenticated())
>> plugins/sfPropelActAsCommentableBehaviorPlugin/lib/form/
>> sfCommentingForm.class.php: $comment['author_id'] =
>> sfContext::getInstance()->getUser()->$id_method();
>> plugins/sfPropelActAsCommentableBehaviorPlugin/lib/
>> sfPropelActAsCommentableToolkit.class.php: $session =
>> sfContext::getInstance()->getUser();
>> plugins/sfPropelActAsCommentableBehaviorPlugin/lib/
>> sfPropelActAsCommentableToolkit.class.php: return
>> sfContext::getInstance()->getLogger()->log($e->getMessage());
>> plugins/sfPropelActAsCommentableBehaviorPlugin/lib/
>> sfPropelActAsCommentableToolkit.class.php: $session =
>> sfContext::getInstance()->getUser();
>> plugins/sfPropelActAsCommentableBehaviorPlugin/modules/sfComment/lib/
>> BasesfCommentComponents.class.php: $config = sfContext::getInstance
>> ()->getUser()->isAuthenticated() ? $this->config_user : $this-
>>> config_anonymous;
>> plugins/sfPropelActAsCommentableBehaviorPlugin/modules/sfComment/lib/
>> BasesfCommentComponents.class.php: sfContext::getInstance()-
>>> getResponse()->addStylesheet('/
>>> sfPropelActAsCommentableBehaviorPlugin/
>> css/sf_comment', 'first');
>> plugins/sfPropelActAsCommentableBehaviorPlugin/modules/sfComment/lib/
>> BasesfCommentActions.class.php: if (((sfContext::getInstance()-
>>> getUser()->isAuthenticated()
>> plugins/sfPropelActAsCommentableBehaviorPlugin/README:
>> 'author_id' => sfContext::getInstance()->getUser()->getUserId()
>>
>>
>> So, sfContext is in the sfPropelActAsCommentable plugin, and in
>> sfGuardPlugin and in the base classes. And sfGuard has some kind of
>> fixture file that loads.
>>
>> So how can I call
>>
>> symfony propel:build-all-load
>>
>> ????
>>
>> How do other developers deal with this?
>>
>>
>>
>>
>>
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---