Symfony/Doctrine/SfGuardPlugin: Redirect to requested page (route), and not referrer - redirect

I want to be able to take the user to the requested page after login, but this does not happen with sfGuard.
** My Register action requires SignIn ;) **
On the listing page [http://cim/frontend_dev.php/]
-> user clicks the 'Register' link [#register = register/index]
-> user is taken to 'Signin' page provided by sfGuard
-> after sign-in, user is taken back to the Listing page (instead of Register)
This is quite annoying! But logical, because the referrer is the listing page.
How can I change logic to make #register the referrer? Pl help. thanks
public function executeSignin($request)
{
$user = $this->getUser();
$this->logMessage('Signin>>> form - isAuth() '.$user->isAuthenticated(), 'info');
if ($user->isAuthenticated())
{
$this->getUser()->setAttribute('tenant', $this->getUser()->getGuardUser()->sfuser->Tenant->getID());
return $this->redirect($user->getReferer($request->getReferer()));
}
$class = sfConfig::get('app_sf_guard_plugin_signin_form', 'sfGuardFormSignin');
$this->form = new $class();
$referer = $user->getReferer($request->getReferer());
$this->logMessage('Signin>>> referer: '.$referer, 'info');
$this->logMessage('Signin>>> referer: '.$request->getReferer(), 'info');
if ($request->isMethod('post'))
{
$this->form->bind($request->getParameter('signin'));
if ($this->form->isValid())
{
$values = $this->form->getValues();
$this->getUser()->signin($values['user'], array_key_exists('remember', $values) ? $values['remember'] : false);
$this->getUser()->setAttribute('tenant', $this->getUser()->getGuardUser()->sfuser->Tenant->getID());
$this->logMessage('Signin>>> sfUrl | #homepage: '.sfConfig::get('app_sf_guard_plugin_success_signin_url','#homepage'), 'info');
return $this->redirect("" != $referer ? $referer : sfConfig::get('app_sf_guard_plugin_success_signin_url','#homepage'));
}
}
else
{
if ($request->isXmlHttpRequest())
{
$this->getResponse()->setHeaderOnly(true);
$this->getResponse()->setStatusCode(401);
return sfView::NONE;
}
// if we have been forwarded, then the referer is the current URL
// if not, this is the referer of the current request
$user->setReferer($this->getContext()->getActionStack()->getSize() > 1 ? $request->getUri() : $request->getReferer());
$this->logMessage('Signin>>> oldy: '.$request->getUri(), 'info');
$this->logMessage('Signin>>> oldy: '.$request->getReferer(), 'info');
$module = sfConfig::get('sf_login_module');
if ($this->getModuleName() != $module)
{
return $this->redirect($module.'/'.sfConfig::get('sf_login_action'));
}
$this->getResponse()->setStatusCode(401);
}
}
Trace:
May 27 10:10:14 symfony [info] {sfPatternRouting} Connect sfRoute "sf_guard_signin" (/login)
May 27 10:10:14 symfony [info] {sfPatternRouting} Connect sfRoute "sf_guard_signout" (/logout)
May 27 10:10:14 symfony [info] {sfPatternRouting} Connect sfRoute "sf_guard_password" (/request_password)
May 27 10:10:14 symfony [info] {sfPatternRouting} Match route "register" (/register) for /register with parameters array ( 'module' => 'register', 'action' => 'index',)
May 27 10:10:14 symfony [info] {sfFilterChain} Executing filter "sfGuardRememberMeFilter"
May 27 10:10:14 symfony [info] {sfFilterChain} Executing filter "sfRenderingFilter"
May 27 10:10:14 symfony [info] {sfFilterChain} Executing filter "sfExecutionFilter"
May 27 10:10:14 symfony [info] {registerActions} Call "registerActions->executeIndex()"
May 27 10:10:14 symfony [info] {sfFrontWebController} Redirect to "http://cim/frontend_dev.php/login"
May 27 10:10:14 symfony [info] {sfWebResponse} Send status "HTTP/1.1 302 Found"
May 27 10:10:14 symfony [info] {sfWebResponse} Send header "Location: http://cim/frontend_dev.php/login"
May 27 10:10:14 symfony [info] {sfWebResponse} Send header "Content-Type: text/html; charset=utf-8"
May 27 10:10:14 symfony [info] {sfWebDebugLogger} Configuration 13.39 ms (9)
May 27 10:10:14 symfony [info] {sfWebDebugLogger} Factories 50.02 ms (1)
May 27 10:10:14 symfony [info] {sfWebDebugLogger} Action "register/index" 1.94 ms (1)
May 27 10:10:14 symfony [info] {sfWebResponse} Send content (104 o)
May 27 10:10:16 symfony [info] {sfPatternRouting} Connect sfRoute "sf_guard_signin" (/login)
May 27 10:10:16 symfony [info] {sfPatternRouting} Connect sfRoute "sf_guard_signout" (/logout)
May 27 10:10:16 symfony [info] {sfPatternRouting} Connect sfRoute "sf_guard_password" (/request_password)
May 27 10:10:16 symfony [info] {sfPatternRouting} Match route "sf_guard_signin" (/login) for /login with parameters array ( 'module' => 'sfGuardAuth', 'action' => 'signin',)
May 27 10:10:16 symfony [info] {sfFilterChain} Executing filter "sfGuardRememberMeFilter"
May 27 10:10:16 symfony [info] {sfFilterChain} Executing filter "sfRenderingFilter"
May 27 10:10:16 symfony [info] {sfFilterChain} Executing filter "sfExecutionFilter"
May 27 10:10:16 symfony [info] {sfGuardAuthActions} Call "sfGuardAuthActions->executeSignin()"
May 27 10:10:16 symfony [info] {sfGuardAuthActions} Signin>>> form - isAuth()
May 27 10:10:16 symfony [info] {sfGuardAuthActions} Signin>>> referer: http://cim/frontend_dev.php/
May 27 10:10:16 symfony [info] {sfGuardAuthActions} Signin>>> referer: http://cim/frontend_dev.php/
May 27 10:10:16 symfony [info] {sfGuardAuthActions} Signin>>> oldy: http://cim/frontend_dev.php/login
May 27 10:10:16 symfony [info] {sfGuardAuthActions} Signin>>> oldy: http://cim/frontend_dev.php/
May 27 10:10:16 symfony [info] {sfPHPView} Render "D:/projects/cim/plugins/sfDoctrineGuardPlugin/modules/sfGuardAuth/templates/signinSuccess.php"
May 27 10:10:16 symfony [info] {sfPHPView} Decorate content with "D:\projects\cim\apps\frontend\templates/layout.php"
May 27 10:10:16 symfony [info] {sfPHPView} Render "D:\projects\cim\apps\frontend\templates/layout.php"
May 27 10:10:16 symfony [info] {main} Get slot "title"
May 27 10:10:16 symfony [info] {sfWebResponse} Send status "HTTP/1.1 401 Unauthorized"
May 27 10:10:16 symfony [info] {sfWebResponse} Send header "Content-Type: text/html; charset=utf-8"
May 27 10:10:16 symfony [info] {sfWebDebugLogger} Configuration 16.06 ms (10)
May 27 10:10:16 symfony [info] {sfWebDebugLogger} Factories 50.00 ms (1)
May 27 10:10:16 symfony [info] {sfWebDebugLogger} Action "sfGuardAuth/signin" 14.53 ms (1)
May 27 10:10:16 symfony [info] {sfWebDebugLogger} View "Success" for "sfGuardAuth/signin" 34.44 ms (1)
May 27 10:10:16 symfony [info] {sfWebResponse} Send content (38057 o)

I think the best way to get the referrer is $request->getReferer()
So far, it has worked well for me!

Related

#Karate Gatling is not generating report when i hit the endpoint once

My Gatling Simulation class,
class <MyClass> extends Simulation {
before {
println("Simulation is about to start!")
}
val smapleTest = scenario("test").exec(karateFeature("classpath:demo/get-user.feature"))
setUp(
smapleTest.inject(rampUsers(1) over (10 seconds))).maxDuration(1 minutes)
//).assertions(global.responseTime.mean.lt(35))
after {
println("Simulation is finished!")
}
}
My get-user.feature file,
Scenario Outline: Hit wskadmin url
Given http://172.17.0.1:5984/whisk_local_subjects/guest
And header Authorization = AdminAuth
And header Content-Type = 'application/json'
When method get
Then status <stat>
* print result
Examples:
| stat |
| 200 |
When i run the simulation class, below console logs i am getting:
Simulation com.karate.openwhisk.performance.SmokePerformanceTest started...
13:20:48.877 [GatlingSystem-akka.actor.default-dispatcher-5] INFO i.gatling.core.controller.Controller - InjectionStopped expectedCount=1
13:20:49.473 [GatlingSystem-akka.actor.default-dispatcher-4] INFO com.intuit.karate - karate.env system property was: null
13:20:49.525 [GatlingSystem-akka.actor.default-dispatcher-7] INFO com.intuit.karate - [print] I am here in get-user
13:20:49.706 [GatlingSystem-akka.actor.default-dispatcher-4] DEBUG com.intuit.karate - request:
1 > GET http://172.17.0.1:5984/whisk_local_subjects/guest
1 > Accept-Encoding: gzip,deflate
1 > Authorization: Basic d2hpc2tfYWRtaW46c29tZV9wYXNzdzByZA==
1 > Connection: Keep-Alive
1 > Content-Type: application/json
1 > Host: 172.17.0.1:5984
1 > User-Agent: Apache-HttpClient/4.5.5 (Java/1.8.0_144)
13:20:49.741 [GatlingSystem-akka.actor.default-dispatcher-4] DEBUG com.intuit.karate - response time in milliseconds: 34
1 < 200
Note: Here i am getting the response in 34 mili seconds, but gating is unable to generate the report. Below is the error message i am getting
Error:
Generating reports...
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at io.gatling.mojo.MainWithArgsInFile.runMain(MainWithArgsInFile.java:50)
at io.gatling.mojo.MainWithArgsInFile.main(MainWithArgsInFile.java:33)
Caused by: java.lang.UnsupportedOperationException: There were no requests sent during the simulation, reports won't be generated
at io.gatling.charts.report.ReportsGenerator.generateFor(ReportsGenerator.scala:48)
at io.gatling.app.RunResultProcessor.generateReports(RunResultProcessor.scala:76)
at io.gatling.app.RunResultProcessor.processRunResult(RunResultProcessor.scala:55)
at io.gatling.app.Gatling$.start(Gatling.scala:68)
at io.gatling.app.Gatling$.fromArgs(Gatling.scala:45)
at io.gatling.app.Gatling$.main(Gatling.scala:37)
at io.gatling.app.Gatling.main(Gatling.scala)
... 6 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.199 s
[INFO] Finished at: 2018-07-24T13:20:50+05:30
[INFO] Final Memory: 30M/332M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.gatling:gatling-maven-plugin:2.2.4:test (default-cli) on project
openwhisk: Gatling failed.: Process exited with an error: 255 (Exit
value: 255) -> [Help 1]
But if i run the same simulation file simple change in feature file as below
Scenario Outline: Hit wskadmin url
Given http://172.17.0.1:5984/whisk_local_subjects/guest
And header Authorization = AdminAuth
And header Content-Type = 'application/json'
When method get
Then status <stat>
* print result
Examples:
| stat |
| 200 |
| 200 |
Then gatling generates the report.
Please help me someone what is the root cause.
Thank you for your interest in karate-gatling and the very detailed report.
This is a bug, which we have fixed and just made a release for.
Can you upgrade your karate-gatling version to 0.8.0.1 and let me know how it goes ?

Gwt Overlay Compilation error whenever method gets used

I am trying to test getting rid of gwt-rpc entrypoints and instead use JAX-RS / JSON based entrypoints.
To do this, I am simply using the native GWT RequestBuilder apis.
As per the documentation here referenced next.
http://www.gwtproject.org/doc/latest/tutorial/JSON.html
The problem I am facing is that the compiler seems unhappy about letting me make use of any overlay API, namely any method that has no java code to be compiled and that is flagged as native.
I am of course using the latest, and greatest, gwt 2.8 compiler.
If I write my overlay as follows.
public class UserLoginGwtRpcMessageOverlay extends JavaScriptObject {
/**
* Mandatory PROTECTED no arguments constructor.
*/
protected UserLoginGwtRpcMessageOverlay() {
super();
}
public final native String getUserName(); /*
* { return userName; }
*/
public final native String getHashedPassword(); /*
* { return hashedPassword;
* }
*/
public final String toStringOverlay() {
return getUserName() + "-" + getHashedPassword();
}
The class will not compile.
And it will not compile because my artifical toString is making use of the overlay APIs, e.g. ( getUserName()).
If I were to take those calls out of the class, it the compiler would not break handling the class.
Going further, If I try to make a rest call as follows:
private void invokeRestService() {
try {
// (a) prepare the JSON request to the server
RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, JSON_URL);
// (b) send an HTTP Json request
Request request = builder.sendRequest(null, new RequestCallback() {
// (i) callback handler when there is an error
public void onError(Request request, Throwable exception) {
LOGGER.log(Level.SEVERE, "Couldn't retrieve JSON", exception);
}
// (ii) callback result on success
public void onResponseReceived(Request request, Response response) {
if (200 == response.getStatusCode()) {
UserLoginGwtRpcMessageOverlay responseOverlay = JsonUtils
.<UserLoginGwtRpcMessageOverlay>safeEval(response.getText());
LOGGER.info("responseOverlay: " + responseOverlay.getUserName());
} else {
LOGGER.log(Level.SEVERE, "Couldn't retrieve JSON (" + response.getStatusText() + ")");
}
}
});
} catch (RequestException e) {
LOGGER.log(Level.SEVERE, "Couldn't execute request ", e);
}
}
Again, the compilation shall fail.
Once more this is the result of me trying to use the getUserName().
In particular, the followig line of code breaks the compiler.
LOGGER.info("responseOverlay: " + responseOverlay.getUserName());
Given that the compiler is running null pointer exceptions giving no other hint besides:
<no source info>: <source info not available>
I suspect I am dealing either with a compiler bug, or a feature that somehow got de-supported and whose APIs still linger. But at the same time, I would be surprised as I would assume overlays to be a core part of GWT, this should just work. So more likely I have some bug in the code I am not spotting.
QUOTE FULL compile error:
[INFO] --- gwt-maven-plugin:2.8.0:compile (gwt-compile) #
jntl-expenses-frontend --- [INFO] Compiling module
org.gwtproject.tutorial.TodoList [INFO] Compiling 1 permutation
[INFO] Compiling permutation 0... [INFO] [ERROR] An
internal compiler exception occurred [INFO]
com.google.gwt.dev.jjs.InternalCompilerException: Unexpected error
during visit. [INFO] at
com.google.gwt.dev.jjs.ast.JVisitor.translateException(JVisitor.java:111)
[INFO] at
com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:276)
[INFO] at
com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
[INFO] at
com.google.gwt.dev.jjs.impl.MakeCallsStatic$CreateStaticImplsVisitor.visit(MakeCallsStatic.java:222)
[INFO] at
com.google.gwt.dev.jjs.ast.JMethod.traverse(JMethod.java:777) [INFO]
at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:127)
[INFO] at
com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:122) [INFO]
at
com.google.gwt.dev.jjs.impl.MakeCallsStatic$CreateStaticImplsVisitor.getOrCreateStaticImpl(MakeCallsStatic.java:240)
[INFO] at
com.google.gwt.dev.jjs.impl.Devirtualizer$RewriteVirtualDispatches.ensureDevirtualVersionExists(Devirtualizer.java:271)
[INFO] at
com.google.gwt.dev.jjs.impl.Devirtualizer$RewriteVirtualDispatches.endVisit(Devirtualizer.java:160)
[INFO] at
com.google.gwt.dev.jjs.ast.JMethodCall.traverse(JMethodCall.java:268)
[INFO] at
com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
[INFO] at
com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
[INFO] at
com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
[INFO] at
com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:118) [INFO]
at
com.google.gwt.dev.jjs.ast.JBinaryOperation.traverse(JBinaryOperation.java:89)
[INFO] at
com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
[INFO] at
com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
[INFO] at
com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
[INFO] at
com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:118) [INFO]
at
com.google.gwt.dev.jjs.ast.JExpressionStatement.traverse(JExpressionStatement.java:42)
[INFO] at
com.google.gwt.dev.jjs.ast.JModVisitor$ListContext.traverse(JModVisitor.java:88)
[INFO] at
com.google.gwt.dev.jjs.ast.JModVisitor.acceptWithInsertRemove(JModVisitor.java:331)
[INFO] at com.google.gwt.dev.jjs.ast.JBlock.traverse(JBlock.java:92)
[INFO] at
com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
[INFO] at
com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
[INFO] at
com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:139) [INFO]
at
com.google.gwt.dev.jjs.ast.JIfStatement.traverse(JIfStatement.java:53)
[INFO] at
com.google.gwt.dev.jjs.ast.JModVisitor$ListContext.traverse(JModVisitor.java:88)
[INFO] at
com.google.gwt.dev.jjs.ast.JModVisitor.acceptWithInsertRemove(JModVisitor.java:331)
[INFO] at com.google.gwt.dev.jjs.ast.JBlock.traverse(JBlock.java:92)
[INFO] at
com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
[INFO] at
com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
[INFO] at
com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:139) [INFO]
at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:135)
[INFO] at
com.google.gwt.dev.jjs.ast.JMethodBody.traverse(JMethodBody.java:83)
[INFO] at
com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
[INFO] at
com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
[INFO] at
com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
[INFO] at
com.google.gwt.dev.jjs.ast.JMethod.visitChildren(JMethod.java:786)
[INFO] at
com.google.gwt.dev.jjs.ast.JMethod.traverse(JMethod.java:778) [INFO]
at
com.google.gwt.dev.jjs.ast.JModVisitor$ListContextImmutable.traverse(JModVisitor.java:169)
[INFO] at
com.google.gwt.dev.jjs.ast.JModVisitor.acceptWithInsertRemoveImmutable(JModVisitor.java:336)
[INFO] at
com.google.gwt.dev.jjs.ast.JClassType.traverse(JClassType.java:147)
[INFO] at
com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
[INFO] at
com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
[INFO] at
com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
[INFO] at
com.google.gwt.dev.jjs.ast.JProgram.visitModuleTypes(JProgram.java:1284)
[INFO] at
com.google.gwt.dev.jjs.ast.JProgram.traverse(JProgram.java:1249)
[INFO] at
com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
[INFO] at
com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
[INFO] at
com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
[INFO] at
com.google.gwt.dev.jjs.impl.Devirtualizer.execImpl(Devirtualizer.java:409)
[INFO] at
com.google.gwt.dev.jjs.impl.Devirtualizer.exec(Devirtualizer.java:324)
[INFO] at
com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.normalizeSemantics(JavaToJavaScriptCompiler.java:489)
[INFO] at
com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.compilePermutation(JavaToJavaScriptCompiler.java:364)
[INFO] at
com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.compilePermutation(JavaToJavaScriptCompiler.java:272)
[INFO] at
com.google.gwt.dev.CompilePerms.compile(CompilePerms.java:198) [INFO]
at
com.google.gwt.dev.ThreadedPermutationWorkerFactory$ThreadedPermutationWorker.compile(ThreadedPermutationWorkerFactory.java:50)
[INFO] at
com.google.gwt.dev.PermutationWorkerFactory$Manager$WorkerThread.run(PermutationWorkerFactory.java:74)
[INFO] at java.lang.Thread.run(Thread.java:745) [INFO] Caused by:
java.lang.NullPointerException [INFO] at
com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
[INFO] at
com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
[INFO] ... 59 more [INFO] [ERROR] : [INFO] [ERROR] at
UserLoginGwtRpcMessageOverlay.java(23):
org.gwtproject.tutorial.client.overlay.UserLoginGwtRpcMessageOverlay.getUserName()Ljava/lang/String;
[INFO] com.google.gwt.dev.jjs.ast.JMethod [INFO]
[ERROR] at TodoList.java(148): responseOverlay.getUserName() [INFO]
com.google.gwt.dev.jjs.ast.JMethodCall [INFO] [ERROR] at
TodoList.java(148): "responseOverlay: " +
responseOverlay.getUserName() [INFO]
com.google.gwt.dev.jjs.ast.JBinaryOperation [INFO] [ERROR] at
TodoList.java(148): "responseOverlay: " +
responseOverlay.getUserName() [INFO]
com.google.gwt.dev.jjs.ast.JExpressionStatement [INFO]
[ERROR] at TodoList.java(145): { [INFO] final
UserLoginGwtRpcMessageOverlay responseOverlay =
(UserLoginGwtRpcMessageOverlay)
JsonUtils.safeEval(response.getText()); [INFO] TodoList.$clinit();
[INFO] "responseOverlay: " + responseOverlay.getUserName(); [INFO] }
[INFO] com.google.gwt.dev.jjs.ast.JBlock [INFO]
[ERROR] at TodoList.java(145): if (200 == response.getStatusCode()) {
[INFO] final UserLoginGwtRpcMessageOverlay responseOverlay =
(UserLoginGwtRpcMessageOverlay)
JsonUtils.safeEval(response.getText()); [INFO] TodoList.$clinit();
[INFO] "responseOverlay: " + responseOverlay.getUserName(); [INFO] }
else { [INFO] TodoList.$clinit(); [INFO] Level.$clinit(); [INFO]
"Couldn\'t retrieve JSON (" + response.getStatusText() + ")"; [INFO] }
[INFO] com.google.gwt.dev.jjs.ast.JIfStatement [INFO]
[ERROR] at TodoList.java(144): { [INFO] if (200 ==
response.getStatusCode()) { [INFO] final
UserLoginGwtRpcMessageOverlay responseOverlay =
(UserLoginGwtRpcMessageOverlay)
JsonUtils.safeEval(response.getText()); [INFO] TodoList.$clinit();
[INFO] "responseOverlay: " + responseOverlay.getUserName(); [INFO]
} else { [INFO] TodoList.$clinit(); [INFO] Level.$clinit();
[INFO] "Couldn\'t retrieve JSON (" + response.getStatusText() +
")"; [INFO] } [INFO] } [INFO]
com.google.gwt.dev.jjs.ast.JBlock [INFO] [ERROR] at
TodoList.java(144): { [INFO] if (200 == response.getStatusCode()) {
[INFO] final UserLoginGwtRpcMessageOverlay responseOverlay =
(UserLoginGwtRpcMessageOverlay)
JsonUtils.safeEval(response.getText()); [INFO] TodoList.$clinit();
[INFO] "responseOverlay: " + responseOverlay.getUserName(); [INFO]
} else { [INFO] TodoList.$clinit(); [INFO] Level.$clinit();
[INFO] "Couldn\'t retrieve JSON (" + response.getStatusText() +
")"; [INFO] } [INFO] } [INFO]
com.google.gwt.dev.jjs.ast.JMethodBody [INFO] [ERROR] at
TodoList.java(144):
org.gwtproject.tutorial.client.TodoList$3.onResponseReceived(Lcom/google/gwt/http/client/Request;Lcom/google/gwt/http/client/Response;)V
[INFO] com.google.gwt.dev.jjs.ast.JMethod [INFO]
[ERROR] at TodoList.java(136):
org.gwtproject.tutorial.client.TodoList$3 (final extends Object
implements RequestCallback) [INFO]
com.google.gwt.dev.jjs.ast.JClassType [INFO] [ERROR] at
Unknown(0): [INFO]
com.google.gwt.dev.jjs.ast.JProgram
Is anyone else experiencing problems in GWT 2.8 with overlays, or am I making some sort of mistake of which I am not aware.
Kind regards,
Any good pointer is appreciated.
public final native String getUserName(); /*
* { return userName; }
*/
This is not valid JSNI (with the same issue in getHashedPassword()). The correct way to write this would be
public final native String getUserName() /*-{
return userName;
}-*/;
You must start with /*-{ and end with }-*/;, and not have *s inbetween like Javadoc might.
However, as JS, that doesn't make any sense, so while it will compile, it isn't what you want. The body of the method should read
return this.userName;
since JS doesn't have an implicit this like Java does.
At a brief glance, the rest looks okay, but without legal JSNI, the compiler cannot accept it.

org.scalajs.jsenv.ExternalJSEnv$NonZeroExitException: PhantomJS2 exited with code 2

I am using scalatest as my testing framework, here is my test code :
import org.scalatest.FunSuite
class SampleTest extends FunSuite{
test("hello") {
println(s"sdfsf")
}
}
build.sbt settings
val scalatestJS = libraryDependencies += "org.scalatest" %%% "scalatest" % Version.scalatest % Test
val scalatestJSSettings = Seq(
scalatestJS,
scalaJSStage in Global := FastOptStage,
// scalaJSStage in Global := FullOptStage,
// jsDependencies += RuntimeDOM,
// jsDependencies += ProvidedJS / "test-bundle.js" % Test,
jsEnv in Test := new PhantomJS2Env(scalaJSPhantomJSClassLoader.value, addArgs = Seq("--web-security=no"))
// jsEnv in Test := new NodeJSEnv()
)
Debug out :
[debug] Scala compilation took 0.961938628 s
[debug] Invalidating client/SampleTest.scala...
[debug] Invalidating (transitively) by inheritance from client/SampleTest.scala...
[debug] Initial set of included nodes: Set(client/SampleTest.scala)
[debug] Invalidated by transitive inheritance dependency: Set(client/SampleTest.scala)
[debug] The client/SampleTest.scala source file has the following implicit definitions changed:
[debug] unconstrainedEquality, convertToEqualizer.
[debug] All member reference dependencies will be considered within this context.
[debug] New invalidations:
[debug] Set()
[debug] Initial set of included nodes: Set()
[debug] Previously invalidated, but (transitively) depend on new invalidations:
[debug] Set()
[debug] All newly invalidated sources after taking into account (previously) recompiled sources:Set()
[debug] Copy resource mappings:
[debug]
[info] Fast optimizing client/assets/client-test-fastopt.js
[debug] Linker: Compute reachability: 710892 us
[debug] Linker: Assemble LinkedClasses: 445560 us
[debug] Basic Linking: 1168893 us
[debug] Inc. optimizer: Batch mode: true
[debug] Inc. optimizer: Incremental part: 127681 us
[debug] Inc. optimizer: Optimizing 11793 methods.
[debug] Inc. optimizer: Optimizer part: 5987357 us
[debug] Inc. optimizer: 6140114 us
[debug] Refiner: Compute reachability: 243271 us
[debug] Refiner: Assemble LinkedClasses: 27389 us
[debug] Refiner: 272567 us
[debug] Emitter: Class tree cache stats: reused: 0 -- invalidated: 1375
[debug] Emitter: Method tree cache stats: resued: 0 -- invalidated: 6643
[debug] Emitter (write output): 1353125 us
[debug] Global IR cache stats: reused: 0 -- invalidated: 130 -- trees read: 1748
[debug] Loading JSEnv with linked file client/assets/client-test-fastopt.js
org.scalajs.jsenv.ExternalJSEnv$NonZeroExitException: PhantomJS2 exited with code 2
at org.scalajs.jsenv.ExternalJSEnv$AbstractExtRunner.waitForVM(ExternalJSEnv.scala:107)
at org.scalajs.jsenv.ExternalJSEnv$ExtRunner.run(ExternalJSEnv.scala:156)
at org.scalajs.sbtplugin.FrameworkDetector.detect(FrameworkDetector.scala:66)
at org.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$60.apply(ScalaJSPluginInternal.scala:737)
at org.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$60.apply(ScalaJSPluginInternal.scala:720)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
at sbt.std.Transform$$anon$4.work(System.scala:63)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.Execute.work(Execute.scala:235)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[error] (client/test:loadedTestFrameworks) org.scalajs.jsenv.ExternalJSEnv$NonZeroExitException: PhantomJS2 exited with code 2
[error] Total time: 15 s, completed May 20, 2016 12:20:29 AM
Note : This is used to work fine but not anymore :s
Edit :
ScalaTest : 3.0.0-M15
ScalaJS : 0.6.9
Scala : 2.11.8
Phantom JS : 2.0.0
In my code i have a class which extends js class
#ScalaJSDefined
class MyLab(container : dom.Node) extends JSLab(container) {... }
even though i am not using this class in my tests,looks like source code generated for this line is some how looking for JSLab in global! which causes crash of phantomjs. Interestingly tests are executing fine on Rhino :s. anyhow i added JSLab as test dependency and error gone.
I don't know whom to blame here , whether its stupid developer(me) who went in different direction while solving problem or scala.js for not helpful in why phantomjs crashed :s

Why is my spring boot stateless filter being called twice?

I'm trying to implement stateless token-based authentication on a rest api I've developed using Spring Boot. The idea is that the client includes a JWT token with any request, and a filter extracts this from the request, and sets up the SecurityContext with a relevant Authentication object based on the contents of the token. The request is then routed as normal, and secured using #PreAuthorize on the mapped method.
My security config is as follows :
#Configuration
#EnableWebSecurity
#EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter {
#Autowired
private JWTTokenAuthenticationService authenticationService;
#Override
protected void configure(HttpSecurity http) throws Exception
{
http
.csrf().disable()
.headers().addHeaderWriter(new XFrameOptionsHeaderWriter(XFrameOptionsMode.SAMEORIGIN))
.and()
.authorizeRequests()
.antMatchers("/auth/**").permitAll()
.antMatchers("/api/**").authenticated()
.and()
.addFilterBefore(new StatelessAuthenticationFilter(authenticationService), UsernamePasswordAuthenticationFilter.class);
}
With the stateless filter that extends GenericFilterBean defined as follows :
public class StatelessAuthenticationFilter extends GenericFilterBean {
private static Logger logger = Logger.getLogger(StatelessAuthenticationFilter.class);
private JWTTokenAuthenticationService authenticationservice;
public StatelessAuthenticationFilter(JWTTokenAuthenticationService authenticationService)
{
this.authenticationservice = authenticationService;
}
#Override
public void doFilter( ServletRequest request,
ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
Authentication authentication = authenticationservice.getAuthentication(httpRequest);
SecurityContextHolder.getContext().setAuthentication(authentication);
logger.info("===== Security Context before request =====");
logger.info("Request for: " + httpRequest.getRequestURI());
logger.info(SecurityContextHolder.getContext().getAuthentication());
logger.info("===========================================");
chain.doFilter(request, response);
SecurityContextHolder.getContext().setAuthentication(null);
logger.info("===== Security Context after request =====");
logger.info("Request for: " + httpRequest.getRequestURI());
logger.info(SecurityContextHolder.getContext().getAuthentication());
logger.info("===========================================");
}
}
And the endpoint defined like this :
#PreAuthorize("hasAuthority('user')")
#RequestMapping ( value="/api/attachments/{attachmentId}/{fileName:.+}",
method = RequestMethod.GET)
public ResponseEntity<byte[]> getAttachedDocumentEndpoint(#PathVariable String attachmentId, #PathVariable String fileName)
{
logger.info("GET called for /attachments/" + attachmentId + "/" + fileName);
// do something to get the file, and return ResponseEntity<byte[]> object
}
When doing a GET on /api/attachments/someattachment/somefilename, including the token, I can see that the filter is being invoked twice, once apparently with the token, and once without. But the restcontroller mapped to the request is only called once.
[INFO] [06-04-2015 12:26:44,465] [JWTTokenAuthenticationService] getAuthentication - Getting authentication based on token supplied in HTTP Header
[INFO] [06-04-2015 12:26:44,473] [StatelessAuthenticationFilter] doFilter - ===== Security Context before request =====
[INFO] [06-04-2015 12:26:44,473] [StatelessAuthenticationFilter] doFilter - Request for: /api/attachments/1674b08b6bbd54a6efaff4a780001a9e/jpg.png
[INFO] [06-04-2015 12:26:44,474] [StatelessAuthenticationFilter] doFilter - Name:iser, Principal:user, isAuthenticated:true, grantedAuthorites:[user]
[INFO] [06-04-2015 12:26:44,474] [StatelessAuthenticationFilter] doFilter - ===========================================
[INFO] [06-04-2015 12:26:44,476] [AttachmentRESTController] getAttachedDocumentEndpoint - GET called for /api/attachments/1674b08b6bbd54a6efaff4a780001a9e/jpg.png
[INFO] [06-04-2015 12:26:44,477] [AttachmentDBController] getAttachment - getAttachment method called with attachmentId:1674b08b6bbd54a6efaff4a780001a9e , and fileName:jpg.png
[INFO] [06-04-2015 12:26:44,483] [StatelessAuthenticationFilter] doFilter - ===== Security Context after request =====
[INFO] [06-04-2015 12:26:44,484] [StatelessAuthenticationFilter] doFilter - Request for: /api/attachments/1674b08b6bbd54a6efaff4a780001a9e/jpg.png
[INFO] [06-04-2015 12:26:44,484] [StatelessAuthenticationFilter] doFilter -
[INFO] [06-04-2015 12:26:44,484] [StatelessAuthenticationFilter] doFilter - ===========================================
[INFO] [06-04-2015 12:26:44,507] [JWTTokenAuthenticationService] getAuthentication - No token supplied in HTTP Header
[INFO] [06-04-2015 12:26:44,507] [StatelessAuthenticationFilter] doFilter - ===== Security Context before request =====
[INFO] [06-04-2015 12:26:44,507] [StatelessAuthenticationFilter] doFilter - Request for: /api/attachments/1674b08b6bbd54a6efaff4a780001a9e/jpg.png
[INFO] [06-04-2015 12:26:44,507] [StatelessAuthenticationFilter] doFilter -
[INFO] [06-04-2015 12:26:44,508] [StatelessAuthenticationFilter] doFilter - ===========================================
[INFO] [06-04-2015 12:26:44,508] [StatelessAuthenticationFilter] doFilter - ===== Security Context after request =====
[INFO] [06-04-2015 12:26:44,508] [StatelessAuthenticationFilter] doFilter - Request for: /api/attachments/1674b08b6bbd54a6efaff4a780001a9e/jpg.png
[INFO] [06-04-2015 12:26:44,508] [StatelessAuthenticationFilter] doFilter -
[INFO] [06-04-2015 12:26:44,508] [StatelessAuthenticationFilter] doFilter - ===========================================
What's going on here ?
Edit :
It's even stranger than I first thought - implementing a simple endpoint that just returns a simple message displays the expected behaviour - it's seems like only when I try to return data as a ResponseEntity as above does this problem occur.
Endpoint :
#PreAuthorize("hasAuthority('user')")
#RequestMapping("/api/userHelloWorld")
public String userHelloWorld()
{
return "Hello Secure User World";
}
Output, showing single call to filter (with extra debug on):
[INFO] [06-04-2015 19:43:25,831] [JWTTokenAuthenticationService] getAuthentication - Getting authentication based on token supplied in HTTP Header
[INFO] [06-04-2015 19:43:25,844] [StatelessAuthenticationFilter] doFilterInternal - ===== Security Context before request =====
[INFO] [06-04-2015 19:43:25,844] [StatelessAuthenticationFilter] doFilterInternal - Request for: /api/userHelloWorld
[INFO] [06-04-2015 19:43:25,844] [StatelessAuthenticationFilter] doFilterInternal - Response = null 200
[INFO] [06-04-2015 19:43:25,844] [StatelessAuthenticationFilter] doFilterInternal - Name:user, Principal:user, isAuthenticated:true, grantedAuthorites:[user]
[INFO] [06-04-2015 19:43:25,845] [StatelessAuthenticationFilter] doFilterInternal - ===========================================
[DEBUG] [06-04-2015 19:43:25,845] [DispatcherServlet] doService - DispatcherServlet with name 'dispatcherServlet' processing GET request for [/api/userHelloWorld]
[DEBUG] [06-04-2015 19:43:25,847] [AbstractHandlerMethodMapping] getHandlerInternal - Looking up handler method for path /api/userHelloWorld
[DEBUG] [06-04-2015 19:43:25,848] [AbstractHandlerMethodMapping] getHandlerInternal - Returning handler method [public java.lang.String RESTController.userHelloWorld()]
[DEBUG] [06-04-2015 19:43:25,849] [DispatcherServlet] doDispatch - Last-Modified value for [/api/userHelloWorld] is: -1
[DEBUG] [06-04-2015 19:43:25,851] [AbstractMessageConverterMethodProcessor] writeWithMessageConverters - Written [Hello Secure User World] as "text/plain;charset=UTF-8" using [org.springframework.http.converter.StringHttpMessageConverter#3eaf6fe7]
[DEBUG] [06-04-2015 19:43:25,852] [DispatcherServlet] processDispatchResult - Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
[DEBUG] [06-04-2015 19:43:25,852] [FrameworkServlet] processRequest - Successfully completed request
[INFO] [06-04-2015 19:43:25,852] [StatelessAuthenticationFilter] doFilterInternal - ===== Security Context after request =====
[INFO] [06-04-2015 19:43:25,853] [StatelessAuthenticationFilter] doFilterInternal - Request for: /api/userHelloWorld
[INFO] [06-04-2015 19:43:25,853] [StatelessAuthenticationFilter] doFilterInternal - Response = text/plain;charset=UTF-8 200
[INFO] [06-04-2015 19:43:25,853] [StatelessAuthenticationFilter] doFilterInternal -
[INFO] [06-04-2015 19:43:25,853] [StatelessAuthenticationFilter] doFilterInternal - ===========================================
It is a part of filters that has still some black magic for me (*), but I know that this is a common problem, and Spring has a subclass of GenericFilterBean specially for dealing with it : just use OncePerRequestFilter as base class and your filter should be called only once.
(*) I've read it could be caused by the request being dispatched multiple times via the request dispatcher
Okay - so this is pretty ridiculous, but it seems like it's an issue with the way I was invoking the request (via the POSTMAN Chrome Extension)
Postman seems to fire in 2 requests, one with headers, one without. There's an open bug report describing this here :
https://github.com/a85/POSTMan-Chrome-Extension/issues/615
The behaviour is not seen if the request is invoked using curl, or just straight from the browser.

TypeError: expected string or Unicode object, long found (Flask app)

This is my views.py:
# -*- coding: utf-8 -*-
from flask import Blueprint, request, render_template, flash, g, session, redirect, url_for
from flask.ext.login import login_user, logout_user, current_user, login_required
from app import db
from app.users.models import User
from app.news.models import News, NewsImg
from app.main.forms import LoginForm
mod = Blueprint('main', __name__, url_prefix='/')
#mod.route('/', methods=['GET', 'POST'])
def main():
form = LoginForm()
if form.validate_on_submit():
username = request.form['username']
password = request.form['password']
user = User.query.filter_by(username=username, password=password).first()
if user is None:
flash('Incorrect login or password', 'error')
return redirect("/")
login_user(user)
return redirect("/")
news = News.query.order_by(News.putdate.desc()).limit(3)
return render_template("main/main.html",
news= news,
form = form)
After authorization (Flask-Login) in logs an error:
TypeError: expected string or Unicode object, long found
On the local machine it works, the problem only on the server
[Fri Feb 06 10:58:01 2015] [error] [client 81.24.82.162] mod_wsgi
(pid=59836): Exception occurred processing WSGI script
'/home/users/s/sadwolf/domains/e-dag.com/dad.wsgi'., referer: url [Fri
Feb 06 10:58:01 2015] [error] [client 81.24.82.162] Traceback (most
recent call last):, referer: url [Fri Feb 06 10:58:01 2015] [error]
[client 81.24.82.162] File
"/home/users/s/sadwolf/virtualenv/dagavtodor/lib/python2.7/site-packages/flask/app.py",
line 1836, in call, referer: url [Fri Feb 06 10:58:01 2015]
[error] [client 81.24.82.162] return self.wsgi_app(environ,
start_response), referer: url [Fri Feb 06 10:58:01 2015] [error]
[client 81.24.82.162] File
"/home/users/s/sadwolf/virtualenv/dagavtodor/lib/python2.7/site-packages/flask/app.py",
line 1820, in wsgi_app, referer: url [Fri Feb 06 10:58:01 2015]
[error] [client 81.24.82.162] response =
self.make_response(self.handle_exception(e)), referer: url [Fri Feb 06
10:58:01 2015] [error] [client 81.24.82.162] File
"/home/users/s/sadwolf/virtualenv/dagavtodor/lib/python2.7/site-packages/flask/app.py",
line 1403, in handle_exception, referer: url [Fri Feb 06 10:58:01
2015] [error] [client 81.24.82.162] reraise(exc_type, exc_value,
tb), referer: url [Fri Feb 06 10:58:01 2015] [error] [client
81.24.82.162] File "/home/users/s/sadwolf/virtualenv/dagavtodor/lib/python2.7/site-packages/flask/app.py",
line 1817, in wsgi_app, referer: url [Fri Feb 06 10:58:01 2015]
[error] [client 81.24.82.162] response =
self.full_dispatch_request(), referer: url [Fri Feb 06 10:58:01 2015]
[error] [client 81.24.82.162] File
"/home/users/s/sadwolf/virtualenv/dagavtodor/lib/python2.7/site-packages/flask/app.py",
line 1477, in full_dispatch_request, referer: url [Fri Feb 06 10:58:01
2015] [error] [client 81.24.82.162] rv =
self.handle_user_exception(e), referer: url [Fri Feb 06 10:58:01 2015]
[error] [client 81.24.82.162] File
"/home/users/s/sadwolf/virtualenv/dagavtodor/lib/python2.7/site-packages/flask/app.py",
line 1381, in handle_user_exception, referer: url [Fri Feb 06 10:58:01
2015] [error] [client 81.24.82.162] reraise(exc_type, exc_value,
tb), referer: url [Fri Feb 06 10:58:01 2015] [error] [client
81.24.82.162] File "/home/users/s/sadwolf/virtualenv/dagavtodor/lib/python2.7/site-packages/flask/app.py",
line 1475, in full_dispatch_request, referer: url [Fri Feb 06 10:58:01
2015] [error] [client 81.24.82.162] rv = self.dispatch_request(),
referer: url [Fri Feb 06 10:58:01 2015] [error] [client 81.24.82.162]
File
"/home/users/s/sadwolf/virtualenv/dagavtodor/lib/python2.7/site-packages/flask/app.py",
line 1461, in dispatch_request, referer: url [Fri Feb 06 10:58:01
2015] [error] [client 81.24.82.162] return
self.view_functionsrule.endpoint, referer: url [Fri
Feb 06 10:58:01 2015] [error] [client 81.24.82.162] File
"/home/users/s/sadwolf/prj/dad/app/main/views.py", line 17, in main,
referer: url [Fri Feb 06 10:58:01 2015] [error] [client 81.24.82.162]
user = User.query.filter_by(username=username,
password=password).first(), referer: url [Fri Feb 06 10:58:01 2015]
[error] [client 81.24.82.162] File
"/home/users/s/sadwolf/virtualenv/dagavtodor/lib/python2.7/site-packages/sqlalchemy/orm/query.py",
line 2367, in first, referer: url [Fri Feb 06 10:58:01 2015] [error]
[client 81.24.82.162] ret = list(self[0:1]), referer: url [Fri Feb
06 10:58:01 2015] [error] [client 81.24.82.162] File
"/home/users/s/sadwolf/virtualenv/dagavtodor/lib/python2.7/site-packages/sqlalchemy/orm/query.py",
line 2228, in getitem, referer: url [Fri Feb 06 10:58:01 2015]
[error] [client 81.24.82.162] return list(res), referer: url [Fri
Feb 06 10:58:01 2015] [error] [client 81.24.82.162] File
"/home/users/s/sadwolf/virtualenv/dagavtodor/lib/python2.7/site-packages/sqlalchemy/orm/loading.py",
line 73, in instances, referer: url [Fri Feb 06 10:58:01 2015] [error]
[client 81.24.82.162] rows = [process[0](row, None) for row in
fetch], referer: url [Fri Feb 06 10:58:01 2015] [error] [client
81.24.82.162] File "/home/users/s/sadwolf/virtualenv/dagavtodor/lib/python2.7/site-packages/sqlalchemy/orm/loading.py",
line 455, in _instance, referer: url [Fri Feb 06 10:58:01 2015]
[error] [client 81.24.82.162] populate_state(state, dict_, row,
isnew, only_load_props), referer: url [Fri Feb 06 10:58:01 2015]
[error] [client 81.24.82.162] File
"/home/users/s/sadwolf/virtualenv/dagavtodor/lib/python2.7/site-packages/sqlalchemy/orm/loading.py",
line 305, in populate_state, referer: url [Fri Feb 06 10:58:01 2015]
[error] [client 81.24.82.162] populator(state, dict_, row),
referer: url [Fri Feb 06 10:58:01 2015] [error] [client 81.24.82.162]
File
"/home/users/s/sadwolf/virtualenv/dagavtodor/lib/python2.7/site-packages/sqlalchemy/orm/strategies.py",
line 169, in fetch_col, referer: url [Fri Feb 06 10:58:01 2015]
[error] [client 81.24.82.162] dict_[key] = row[col], referer: url
[Fri Feb 06 10:58:01 2015] [error] [client 81.24.82.162] TypeError:
expected string or Unicode object, long found, referer: url
Please exchange all your models':
def __repr__(self):
return self.xxx
or
def __str__(self):
return self.xxx
to unicode methods like:
def __unicode__(self):
return unicode(self.xxx)
Because you may shows a long type or null/None type for your model, the __repr__ and __str__ does not support these type.
__unicode__() take effect.
update: data in your locale may not be the same type with your server' data.So this error does not appear on your local machine.