This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » legacy support » symfony 1.1 » propel-generate-crud - The "default" context does not exist.
propel-generate-crud - The "default" context does not exist. [message #59216] Thu, 21 August 2008 15:08 Go to next message
botulotoxin  is currently offline botulotoxin
Messages: 13
Registered: June 2008
Location: Brno, Czech Republic
Junior Member
Hi,

in the past it worked perfectly, but now when I want to generate crud module I only get The "default" context does not exist. error. Tried to upgrade to sf1.1.1, but no change.

Does anybody have solution for this?
Thanks in advance,
Zdenek
Re: propel-generate-crud - The "default" context does not exist. [message #62658 is a reply to message #59216 ] Thu, 09 October 2008 03:21 Go to previous messageGo to next message
ruFog  is currently offline ruFog
Messages: 13
Registered: March 2008
Location: Russia, Khabarovsk
Junior Member

Have you find any solution??? Thanks!
Re: propel-generate-crud - The "default" context does not exist. [message #71550 is a reply to message #59216 ] Thu, 05 February 2009 15:09 Go to previous messageGo to next message
JoeZ99  is currently offline JoeZ99
Messages: 7
Registered: January 2008
Location: havana, cu
Junior Member
hep.
I'm having exactly the same issue.
I have a symfony 1.2 going on, and when trying to issue php symony propel:generate-crud it throws me this exception
The "default" context does not exist

The funny thing is I'm only trying to replicate what it's said in the forms chapter!

anyway, if somebody is willing to help, it'll be more than appreciated.
Re: propel-generate-crud - The "default" context does not exist. [message #71615 is a reply to message #59216 ] Fri, 06 February 2009 07:55 Go to previous messageGo to next message
chryssalid  is currently offline chryssalid
Messages: 1
Registered: February 2009
Location: Poland
Junior Member
Check if you have a call to sfContext in your model. I have such a thing in a save method and this is the reason of the error.

<?php
class Uzytkownik extends BaseUzytkownik
{
   public function 
save(PropelPDO $con null)
   {
      
$this->setUzytkownikHaslo(md5($this->getUzytkownikHaslo()));
      if (
$this->getUzytkownikData() == 0)
      
$this->setUzytkownikData(time());
      
$IP sfContext::getInstance()->getRequest()->getRemoteAddress(); # this line raises an error while using propel:load-data
      
if ($this->getUzytkownikIp() == ''$this->setUzytkownikIp($IP);
      return 
parent::save($con);
   }
}
?>
Re: propel-generate-crud - The "default" context does not exist. [message #72904 is a reply to message #59216 ] Thu, 19 February 2009 11:33 Go to previous messageGo to next message
jarapeno  is currently offline jarapeno
Messages: 1
Registered: February 2009
Junior Member
Hello.

If I think, will not there be a problem in schema.yml?
For example, I appoint default value for the field where you become require=true of the table which generate-crud is going to intend for and do not forget it? .

I remain and I translate it in Yahoo! and contribute it because English is not proud.
I am sorry if it is a strange sentence.
Re: propel-generate-crud - The "default" context does not exist. [message #78534 is a reply to message #72904 ] Sun, 17 May 2009 06:45 Go to previous messageGo to next message
lkrubner  is currently offline lkrubner
Messages: 297
Registered: July 2008
Location: Virginia, USA
Faithful Member
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/52ffa70b40d5 f44d

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/sfCom ment/lib/
BasesfCommentComponents.class.php: $config = sfContext::getInstance
()->getUser()->isAuthenticated() ? $this->config_user : $this-
>config_anonymous;

plugins/sfPropelActAsCommentableBehaviorPlugin/modules/sfCom ment/lib/
BasesfCommentComponents.class.php: sfContext::getInstance()-
>getResponse()->addStylesheet('/sfPropelActAsCommentableBehaviorPlugin/

css/sf_comment', 'first');
plugins/sfPropelActAsCommentableBehaviorPlugin/modules/sfCom ment/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?



Symfony Experts offers answers: http://www.symfonyexperts.com/
Re: propel-generate-crud - The "default" context does not exist. [message #78535 is a reply to message #78534 ] Sun, 17 May 2009 07:12 Go to previous messageGo to next message
lkrubner  is currently offline lkrubner
Messages: 297
Registered: July 2008
Location: Virginia, USA
Faithful Member
Okay, I came up with a ridiculous hack to get this working. I simply wanted to be able to run the "load-data" and "build-all" tasks. This page gives info about how to add sfContext to a task:

http://www.symfony-project.org/book/1_2/16-Application-Manag ement-Tools

So on my machine I opened up these two files:

/usr/share/php/symfony/plugins/sfPropelPlugin/lib/task/sfPropelBuilAllLoadTask.class.php

/usr/share/php/symfony/plugins/sfPropelPlugin/lib/task/sfPropelLoadTask.class.php


And I added this to the top of the file:

require_once('/var/www/apartments/config/
ProjectConfiguration.class.php');

$configuration = ProjectConfiguration::getApplicationConfiguration
('frontend', 'dev', true);

sfContext::createInstance($configuration);


That got the tasks to run. One hell of an ugly hack. I hate editing core files. I feel like there should always be a solution to every problem that doesn't involve editing core fles.



Symfony Experts offers answers: http://www.symfonyexperts.com/
Re: propel-generate-crud - The "default" context does not exist. [message #79995 is a reply to message #78535 ] Wed, 17 June 2009 11:59 Go to previous messageGo to next message
JessOVR  is currently offline JessOVR
Messages: 48
Registered: April 2008
Location: France
Member
hi lkrubner,

I'm facing similar problem ( posted here: http://forum.symfony-project.org/index.php/m/79839/?srch=%22 default%22+context+does+not+exist#msg_79839 ),

like you, hacking core class doesn't satisfy me,

did you find better solution since ?
Re: propel-generate-crud - The "default" context does not exist. [message #84177 is a reply to message #79995 ] Sun, 23 August 2009 02:59 Go to previous messageGo to next message
alinares  is currently offline alinares
Messages: 1
Registered: August 2009
Junior Member
Try adding that same code in the first parsed yml of the fixtures:

<?php
$configuration = ProjectConfiguration::getApplicationConfiguration
('frontend', 'dev', true);

sfContext::createInstance($configuration);
?>
BlogArticle:
  Article:
    id: 1
    title: A title

Re: propel-generate-crud - The "default" context does not exist. [message #97347 is a reply to message #59216 ] Wed, 14 April 2010 12:50 Go to previous messageGo to next message
caponica  is currently offline caponica
Messages: 69
Registered: March 2008
Location: London
Member
You can also create your own custom task that sets up the ProjectConfiguration then calls the core Propel tasks.

If you look at the core files there are plenty of examples of tasks calling other tasks to get you started.
Re: propel-generate-crud - The "default" context does not exist. [message #97407 is a reply to message #59216 ] Thu, 15 April 2010 03:39 Go to previous message
arthurccube  is currently offline arthurccube
Messages: 3
Registered: February 2010
Junior Member
thanks dude , here is my tasks that work!


<?php
/*
override data-load task
to set up context first (otherwise all models cannot use sfContent

require_once(dirname(__FILE__).'/sfDoctrineBaseTask.class.ph p');

*/
class myDoctrineDataLoadTask extends sfDoctrineDataLoadTask
{
/**
* @see sfTask
*/
protected function configure()
{


$this->namespace = 'doctrine';
$this->name = 'mydata-load';
$this->briefDescription = 'Loads YAML fixture data with context loaded';

$this->detailedDescription = <<<EOF
Arthur overriden load data class;
EOF;

}

/**
* @see sfTask
*/
protected function execute($arguments = array(), $options = array())
{
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend' , 'dev', true);

sfContext::createInstance($configuration);
parent::execute($arguments, $options);
}
}
Previous Topic:Unable to scaffold model....
Next Topic:Server memory problems
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software