Does Hypnotoad write any Logfile?
I can't find anything about that here: http://mojolicio.us/perldoc/Mojo/Server/Hypnotoad
Also the option --help says nothing about it.
I understand, that application-wise I need to use stuff like $self->app->log->error('aua!')... but something like a server log does not exist? (e.g. client requests, internal errors, etc)
If the answer is just no, I'm fine.
This would then mean, that I would need to implement this in my application I guess.
I can imagine that it makes sense to keep server-code small and clean here, maybe this would be the reason for a lack of this functionality?
Or is it that I can enable it?
If your application has a log folder, the log will be written there: http://mojolicio.us/perldoc/Mojolicious/Guides/Tutorial#Mode
I don't think so, but it's easy to set one up.
use Mojo::Log;
...
app->log( Mojo::Log->new( path => <filename>, level => 'debug' ) );
...
app->start;
app->log( Mojo::Log->new( path => , level => 'debug' ) );
Insert it to startup function
Related
I was trying to use this function like this:
$test = 'tekst';
Zend_Debug::dump($test);
It does not print anything ...
Maybe this part of code is not actually running? (is this part of larger website?)
Maybe you didn't have Zend loaded, and your PHP shows error (like 'Can't find class Zend_Debug') but you have error_reporting disabled?
The Padrino Admin Guide (http://www.padrinorb.com/guides/padrino-admin) has the object "access_control", but it is not clear to me where it is set? I can guess, but that is not good enough. We have essentially:
class Admin < Padrino::Application
register Padrino::Admin::AccessControl
enable :authentication
set :login_page, "/admin/sessions/new"
access_control.roles_for :any do |role| #How is access_control set?
role.protect "/"
role.allow "/sessions"
end
...
I am expecting that access_control is set somewhere, but where? I am guessing that this has to do with the "register" command, but have not found any help in docs yet.
thanks for any help...
Well, little interest in this, but I needed an answer, so here is mine.
I have at the top register Padrino::Admin::AccessControl which also lists Authorization, Base, ProjectModule. I can see some of the methods used in the app from the docs:
https://www.padrinorb.com/api/Padrino/Admin/AccessControl.html
However, nothing I could see about "access_control". I finally saw in the docs something I had missed, the line:
Defined in:padrino-admin/lib/padrino-admin/access_control.rb
AhHa! That is what I needed. Github if I need to look further.
I am sending myself WebApp error reports from Pylons when users hit critical errors and I would love to be able to get the full output of session[] in the reports and customize it to my liking, but I've got no idea how to do that, or where the report is actually created / put together.
Anyone know how I can accomplish that?
The short answer is that you will have to roll your own for this functionality. WebError is the package used to handle this, and it doesn't provide any extension points. Your best bet may be to use a fork of it with your changes, although even then the code is not pretty.
I thank Michael for answering me, without really giving me anything to build on. That meant I had to figure it out myself, and that's always a good thing :)
What I did was, I looked at /config/middleware.py in my Pylons project and found this line:
app = ErrorHandler(app, global_conf, **config['pylons.errorware'])
I made my own ErrorHandler def and my own ErrorMiddleware class at the top of the middleware.py file:
class ClaraErrorMiddleware(ErrorMiddleware):
def exception_handler(self, exc_info, environ):
# do what ever you want with the exc_info or environ vars
super(ClaraErrorMiddleware, self).exception_handler(exc_info, environ) # call parent
pass
def ClaraErrorHandler(app, global_conf, **errorware):
if asbool(global_conf.get('debug')):
return ErrorHandler(app, global_conf, **errorware)
else:
return ClaraErrorMiddleware(app, global_conf, **errorware)
So now, I can throw in some extra variables I want to be sent with my error emails. Simple enough ...
I'm trying to automatically post to blogger using Perl's Net::Blogger but it keeps returning false and not posting. The main portion of my code looks like this:
use Net::Blogger;
my $blogger = Net::Blogger->new({
debug => 1,
appkey => '0123456789ABCDEF', # doesn't matter?
blogid => $blogid,
username => $username,
password => $password,
});
my $result = $blogger->newPost({
postbody => \'<p>This is text</p><hr/><p><strong>Whee!</strong></p>',
publish => 1,
});
use Data::Dumper;
print Dumper($result);
Sure enough, $result is 0 and in checking the blog, nothing has been posted. The error I'm getting when I enable debugging is:
Element '' can't be allowed in valid XML message.
Died. at /Library/Perl/5.10.1/SOAP/Lite.pm line 1410.
What am I doing wrong?
If you can suggest an alternative to Net::Blogger, that would be fine.
Update: if I don't enable debugging, it hangs for quite a while when trying to post.
I can understand your frustration, I don't like it when I try to use a CPAN module which is seductively named (i.e. looks like a good scratch for the itch) but is ultimately not useful. However, Net::Blogger had its last update in 2006 so I think it would be incredible if it still worked as originally intended, given that blogger has been evolving over the years.
Per daxim's rec, I made a quick attempt to install Atompub on OS X via CPAN.pm, but failed due to a hard dependency on Perl::Critic, which won't install. I figure I know how to fix this but I'll need a better reason than this to go to the effort.
I saw this note in the Net::Blogger perldoc which if nothing else provides a hint on another module to try, for anyone who didn't feel like beating Atompub into submission:
The Atom API
In January 2004, Blogger announced
their support for the Atom API.
As of this writing (version 0.87) this
package does not support the Atom API.
If you need to do things Atom-ish,
your best bet is to use the XML::Atom
package.
Alternative as you requested: after all the different blogging APIs, a standard in the form of RFC 5023 emerged.
Atompub works fine.
I worked a bit with Net::Logger today and managed to publish an entry into Blogger, the problem is that only the body can be set (no Atom supported as virtualsue told).
Please take a look at my Perl Posting to Blogger blues entry for some help.
I am trying to use either APC or XCache as an opcode to cache my php pages. I am using it with Zend and Doctrine and it's having a problem with the autoloader.
If I try with APC, I get the following:
Fatal error: spl_autoload() [<a href='function.spl-autoload'>function.spl-autoload</a>]:
Class Doctrine_Event could not be loaded in
C:\\[mydir]\\library\\doctrine\\Doctrine\\Record.php on line 777
If I try with XCache I get the following:
PHP Fatal error: Cannot redeclare class Zend_Registry in
C:\\[mydir]\\library\\zendframework\\Zend\\Registry.php on line 0
I'm running Zend 1.9.1, Doctrine 1.1 on a windows box.
My bootstrap is as follows:
set_include_path(dirname(__FILE__).'/../library/zendframework'
. PATH_SEPARATOR . dirname(__FILE__).'/../library/doctrine'.....
require 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
$loader->suppressNotFoundWarnings(false);
$loader->setFallbackAutoloader(true);
From what I've read, using APC or xcache is almost a must for performance, but I can't seem to get it working. Any ideas?
You could put a "Zend_Session::writeClose(true);" at the end of your index.php.
This will write the session into a persistent state before necessary Objects (Zend_Loader etc.) get destructed.
Better: Register it as shutdown function.
So it will be executed even if you use exit(), die() or a fatal error occures:
register_shutdown_function(array('Zend_Session', 'writeClose'), true);
It is probably similar to the problem with custom session handling and APC-cache. If you have assigned a custom session handler it is registered with RSHUTDOWN in PHP. It is the same routine that APC uses and will therefor create an internal conflict in PHP and your custom session handler will not close in all situations.
So you will have to make sure you manually close the custom session handler at shutdown
Putting a "Zend_Session::writeClose(true);" at the end of your index.php is not the best way to do that in case you have any exit; calls in your scripts anywhere.
It is better to register a shutdown handler in this way:
function shutdown()
{
Zend_Session::writeClose(true);
}
register_shutdown_function('shutdown');
Put that in top of your index.php file to make sure that the shutdown procedure is registered before any other scripts are run.
Is there something else mucking the include path? Maybe try to log out the include path right before that line in your first APC example.
The XCache one is really weird. That project is pretty dead though, and I'd not trust it on PHP 5.2+. Try eaccelerator instead? We've had the best luck with it.
Benjamin Cremer, you're a life saver. While the above (original) problem is a special case of autoloading with sessions, closing the session seems to be a general solution for such cases. A note though:
Placing Zend_Session::writeClose(true); at the end of your scripts may not always cut it, since you may have exit;'s, die();'s, etc in your code. In this case, you can use
register_shutdown_function(array('Zend_Session', 'writeClose'), true);
or, simply
register_shutdown_function('session_write_close');
if you do not use Zend for sessions.