Hi ,
 I got error like this:

[2010-Dec-27 10:51:41.239569] 4037 [/ SHrtNzkDFewEiUCe] [error] "Error during 
event handling: Cannot map tables after schema was initialized."
[2010-Dec-27 10:51:41.239765] 4037 [/ SHrtNzkDFewEiUCe] [fatal] "Cannot map 
tables after schema was initialized."

I don't understand why how can I map a table to use in two functions ?

/*
   Copyright 2010 Jan Koester

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

#include <cstring>

#include <Wt/WApplication>
#include <Wt/WBreak>
#include <Wt/WStackedWidget>
#include <Wt/WContainerWidget>
#include <Wt/WLineEdit>
#include <Wt/WPushButton>
#include <Wt/WText>
#include <Wt/WWidget> 
#include <Wt/WComboBox> 
#include <Wt/WTextArea>
#include <Wt/WCssStyleSheet>
#include <Wt/WColor>
#include <Wt/WHBoxLayout> 
#include <Wt/WLength>
#include <Wt/WJavaScript>
#include <Wt/WImage>
#include <Wt/WLogger>
#include <curl/curl.h>
#include <tuxlibs/navbar.h>
#include <libtwit/twitcurl.h>
#include "twitter.h"

TuxistApp::TuxistApp(const Wt::WEnvironment& env)
    : Wt::WApplication(env)
{
  Wt::Dbo::backend::Postgres db_con(getenv("TUXCMS_SQLCONFIG")); //will be 
replaced agqainst multi db support
  session.setConnection(db_con);
  setTitle("Tuxist.de");               // application title
  useStyleSheet("style/main.css");
  Navbar navbar;
  navbar.setSession(&session);
  navbar.getNavbar(root());
  twitter.setSession(&session);
  session.flush();
  if(twitter.getLogindata()==false){
    root()->addWidget(new Wt::WText("Please visit this link in web browser and 
authorize this application: "+ twitter.getRequestToken()+"<br />"));
    root()->addWidget(new Wt::WText("Enter the PIN provided by twitter: <br 
/>" ));
    PinLine = new Wt::WLineEdit(root());
    PinLine->enterPressed().connect(SLOT(this, TuxistApp::RegisterApp));
  }
}

void TuxistApp::RegisterApp(){
  twitter.setAuthPin(PinLine->text().toUTF8());  
  twitter.RegisterApp();
}


bool Twitter::getLogindata(){
  Session.mapClass<Twitter>("twitter");
  try {
    Session.createTables();
  }catch (...) { }
  Wt::Dbo::Transaction transaction(Session);
  Accounts accounts;
  accounts = Session.find<Twitter>();
  for (Accounts::const_iterator i = accounts.begin(); i != accounts.end(); 
++i){
    twitterObj.getOAuth().setConsumerKey( std::string( "" ) );
    twitterObj.getOAuth().setConsumerSecret( std::string( "" ) );
    myOAuthAccessTokenKey =  (*i)->oauth_token.toUTF8();
    myOAuthAccessTokenSecret = (*i)->oauth_secret.toUTF8();
    qid = (*i)->id;
    if( myOAuthAccessTokenKey.size() && myOAuthAccessTokenSecret.size() ){
        std::cerr << "Tokenkey: " << myOAuthAccessTokenKey << std::endl << 
"Tokensecret: "<< myOAuthAccessTokenSecret << std::endl;
        twitterObj.getOAuth().setOAuthTokenKey( myOAuthAccessTokenKey );
        twitterObj.getOAuth().setOAuthTokenSecret( myOAuthAccessTokenSecret );
    }else{     
      twitterObj.oAuthRequestToken(RequestToken);
      std::cerr << "Token: " << RequestToken << std::endl;
      transaction.commit();  
      return false;    
    } 
  }
  transaction.commit();  
  return true;
}

void Twitter::RegisterApp(){
  std::cout << "Qid: " << qid << std::endl;
  twitterObj.getOAuth().setOAuthPin(AuthPin);
  twitterObj.oAuthAccessToken();
  twitterObj.getOAuth().getOAuthTokenKey( myOAuthAccessTokenKey );
  twitterObj.getOAuth().getOAuthTokenSecret( myOAuthAccessTokenSecret );  
  
  Session.mapClass<Twitter>("twitter");
  Wt::Dbo::ptr<Twitter> auth = Session.find<Twitter>().where("id = 
?").bind(qid);
  Wt::Dbo::Transaction transaction(Session);
  auth.modify()->oauth_token = myOAuthAccessTokenKey;
  auth.modify()->oauth_secret = myOAuthAccessTokenSecret;
  transaction.commit();  
}

void Twitter::getdata(){

}

Wt::WApplication *createApplication(const Wt::WEnvironment& env)
{
    return new TuxistApp(env);
}

int main(int argc, char **argv)
{
  return WRun(argc, argv, &createApplication);
}

------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to