ANNOUCE: Embperl 2.0.0 final release

2005-08-14 Thread Gerald Richter
The URL

ftp://ftp.dev.ecos.de/pub/perl/embperl/Embperl-2.0.0.tar.gz

has entered CPAN as

  file: $CPAN/authors/id/G/GR/GRICHTER/Embperl-2.0.0.tar.gz
  size: 655012 bytes
   md5: 60e1e6903e2605023fea7a0748be38f7

I am happy to announce the final release of Embperl 2.0.0!

Embperl 2.0.0 contains major enhancements over Embperl 1.3.6, like improved
performance, XML/XSLT handling, customizable syntax, support for
Apache/mod_perl 2, support for application (controler) objects, server and
client side form validation and much more...

---

Embperl is a system for building dynamic websites with Perl.

It gives you the power to embed Perl code in your HTML/XML documents and the
ability to build your Web site out of small reusable objects in an
object-oriented style. 

Embperl has several features which are especially useful for creating
Websites, including dynamic tables, form field processing, URL
escaping/unescaping, session handling, caching, xslt transformation and
more.

See http://perl.apache.org/embperl/ (english) or http://www.ecos.de/embperl/
(german) for more information.


FEATURES


* Embperl facilitates embedding Perl code into HTML/XML or other text
documents. Perl code is evaluated at the server side and the result is sent
to the browser. All available Perl modules can be used without any
restriction.

* Allows to build Web sites out of small reusable components in an
object-oriented way. Components can call and/or embed each other and inherit
from other objects.

* Standard layout of a web-site site can be defined once and the content can
be dynamically generated by these components based on the uri. The documents
need only contain the variable portions but not the common items which
define the layout like headers/footers or navigation bars which normally
form the template. Also these common elements can be overwritten in each
sub-directory.

* Embperl 2.0 thus facilitates separating code, layout and creating MVC
(Model-View-Controller) applications. Control logic can be moved into an
application object, which controls further execution of the request, while
the actual pages are containing the display code. Simple applications can
still embed all the code in the pages.

* Source-code for each component can come from a different source, for eg.
from file, memory or sub-request which allows to act on the output from
another Apache application like PHP, JSP, CGI Script etc.

* Each component can be in a different source format (e.g. HTML, WML, XML,
POD, ...) and can be transformed to other output formats, say by using via
XSLT. 

* Supports one or more scripting syntax using Embperl, ASP, Text, Perl and
others.

* Output generation is divided into small steps where each is processed by a
plugable provider. The interaction of the providers can be individually
configured for each component via recipes.

* Supports caching of intermediate results and output.

* Embperl encompasses several features that ease the task of dynamic
web-site content generation, including dynamic-tables,
form-field-processing, escaping/unescaping, etc.

* Contains a module for easy form input validation, which is able to
validate user input at the server side and on the client side by one
definition of rules.

* Handles per-user and per-module persistent session requiring only storage
and retrieval of the session data from a special hash.

* Offers flexible configuration options to suite individual tastes and
needs.

* Fully integrated into Apache and mod_perl to acheive the best performance.
Can also run as a free standing CGI-script, off-line or can be called from
another Perl program.

* The Perl module DBIx::Recordset offers high level, easy to use database
access for Embperl.

* Embperl::Mail enables redirecting the result output to a mail-recipient.


Enjoy

Gerald


Changes since 2.0rc5:

   - http headers from %http_headers_out will now also be send when the
 init method of an application object return non zero (e.g. 302 for
redirect).
   - Updated xsl stylesheet and css styles of website for better display
 of code sections.
   - Updated db/epwebapp.pl to make it more robust and fix some minor bugs
 and also allows to set edit and view_level (anonymous, login, admin)
 for every table.


---
Gerald Richterecos electronic communication services gmbh
IT-Securitylösungen * Webapplikationen mit Apache/Perl/mod_perl/Embperl

Post:   Tulpenstrasse 5  D-55276 Dienheim b. Mainz
E-Mail: [EMAIL PROTECTED]  Voice:   +49 6133 939-122
WWW:http://www.ecos.de/  Fax: +49 6133 939-333
---
ECOS BB-5000 Firewall- und IT-Security Appliance: www.bb-5000.info
---

 



no cookie on redirect : mod_auth_tkt2

2005-08-14 Thread Marc Lambrichs

I'm trying to build a mp2 handler to login using mod_auth_tkt2. I like the idea 
of probing if
the client can support cookies, so tried to rebuild it. According to the cgi 
example there
is some problem with setting the cookie on a redirect. The same problem - no probe cookie is set 
during the redirect - occurs when I use the following method, and I can't see why.


#-
sub login: method
#-
{
   my ( $class, $r ) = @_;

   #$r->print('sub run ', B::Deparse->new->coderef2text( \&run ));
   my $apr = Apache2::Request->new($r);

   ### Check if there are any cookies defined
   my $jar = Apache2::Cookie::Jar->new( $r );
   my $cookie = $jar->cookies( 'tkt' );
   my $probe  = $jar->cookies( 'probe' );
   my $has_cookies = $cookie ||
 $probe  || '';
   if ( ! $has_cookies ){
  ### if this is a self redirect warn the user about cookie support
  if ( $apr->param( 'redirect' ) ) {
 my @remarks = ( 'Your browser does not appear to support cookies.',
 'This site requires cookies - please turn cookie 
support' );
 my $detail = join '&', map { sprintf "detail=%s", $_ } @remarks;
 $r->internal_redirect_handler( "/error?type=400&$detail" );
 return Apache2::Const::OK;
  }
  ### If no cookies and not a redirect, redirect to self to test cookies.
  else {
 $cookie = Apache2::Cookie->new( $r,
 -name   => "probe",
 -domain => 'my.domain',
 -value  => 1 );
 $cookie->path("/");
 $cookie->bake( $r );
 $r->headers_out->set( Location => "/login?redirect=1" );

 return Apache2::Const::REDIRECT;
  }
   }
}



Re: [mp2] strange behavior of script under heavy load

2005-08-14 Thread Bjoern Hoehrmann
* Bjoern Hoehrmann wrote:
>This is what HTML::Template would generate for the request if no
>parameters are set. Parameters should be set though and this is
>the output even if the corresponding print() is commented out, so
>this output is a bit strange and unexpected. Again, this happens
>only under heavy load, it does not happen for e.g. `ab -c 1 -n 600`
>or at least rarely.

This was apparently caused by code like this

  use File::Temp qw();
  my $fh = File::Temp->new();
  File::Temp::unlink0($fh, $fh->filename);
  print "Content-Type:text/plain\n\n";

On Win32 this would delay unlinking the temp files until File::Temp is
unloaded. For some reason, File::Temp stops creating new temp files
after about 180 files. Using it with stand-alone Perl it should allow
for > 2000 temp files. I'm not sure why File::Temp does not croak here
then or why this causes the strange behavior, but fixing the incorrect
code above solves the problem.

>The test input I'm using should yield in 102 reported errors.
>Under normal load, only 94 errors are reported (the last 8 errors
>are missing), under heavy load, sometimes, 102 erors are reported.

I could track this down to input like

  
  ...

This should result in an error 'element "NOBR" undefined' from OpenSP.
When running it under mod_perl and the winnt mpm however it gives this
message sometimes and 'document type does not allow element "NOBR"
here' on other times. At some point I got different errors for every
other request though it's not that stable anymore. It's not possible
to reproduce this when using debug builds of OpenSP...
-- 
Björn Höhrmann · mailto:[EMAIL PROTECTED] · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 


Re: [mp2] strange behavior of script under heavy load

2005-08-14 Thread Bjoern Hoehrmann
* Bjoern Hoehrmann wrote:
>>The test input I'm using should yield in 102 reported errors.
>>Under normal load, only 94 errors are reported (the last 8 errors
>>are missing), under heavy load, sometimes, 102 erors are reported.
>
>I could track this down to input like
>
>  
>  ...
>
>This should result in an error 'element "NOBR" undefined' from OpenSP.
>When running it under mod_perl and the winnt mpm however it gives this
>message sometimes and 'document type does not allow element "NOBR"
>here' on other times. At some point I got different errors for every
>other request though it's not that stable anymore. It's not possible
>to reproduce this when using debug builds of OpenSP...

This is the result of an unitialized variable in OpenSP. I've fixed it
in the openjade cvs. Hopefully there aren't more gotchas of this kind.
-- 
Björn Höhrmann · mailto:[EMAIL PROTECTED] · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 


web application speed problem with OO modules

2005-08-14 Thread Badai Aqrandista

Hi all,

I'm new to the list and I have a question related to mod_perl... I have 
tried my best to solve the problem, but failed... So I turn to you guys...


I'm currently in the process of optimizing a my company's web application 
that I've rewritten almost from scratch for 4 months. The older version uses 
Apache::Registry, slightly modified cgi scripts and procedural perl modules. 
Whereas the new version is a rewrite of all those into object oriented 
modules, with Template Toolkit as the templating system. The code has become 
much more manageable now.


However, the speed of the new code is a LOT worse than what I had expected. 
I have optimized the code with caches, indexes and rewriting inefficient SQL 
queries. But the speed is still 2 to 4 times slower than the old version for 
the same algorithm. (Of course I only optimized what the profiler tells me).


(I only try to improve the speed of the code, so the use of proxy shouldn't 
be relevant here - I think, I could be wrong).


Does anyone has any other suggestion to improve a web application's speed?
I'd give more details if needed...

Thanks for your attentions...

---
Badai Aqrandista
Cheepy (?)

_
Dating? Try Lavalife – get 7 days FREE! Sign up NOW. 
http://www.lavalife.com/clickthru/clickthru.act?id=ninemsn&context=an99&a=20233&locale=en_AU&_t=33473




Re: web application speed problem with OO modules

2005-08-14 Thread Philip M. Gollucci
(I only try to improve the speed of the code, so the use of proxy 
shouldn't be relevant here - I think, I could be wrong).

You might try using

Apache::DProf
and/or
Apache::SmallProf

available here to see where your code is spending its time

http://search.cpan.org/~fwiles/Apache-DB


Re: web application speed problem with OO modules

2005-08-14 Thread Badai Aqrandista


Thanks for replying...

I have done some profiling with Apache::DProfile, and this is the output of 
'dprofpp tmon.out':


Total Elapsed Time = 160.2141 Seconds
 User+System Time = 13.07412 Seconds
Exclusive Times
%Time ExclSec CumulS #Calls sec/call Csec/c  Name
92.7   12.12 13.575  1   12.127 13.574  ELRes::ApacheHandler::handler
3.13   0.409  0.409  90360   0. 0.  Date::Simple::as_iso
2.20   0.288  0.366  20364   0. 0.  
Params::Validate::_check_regex_fro

m_xs
1.53   0.200  0.200  29966   0. 0.  Date::Simple::DESTROY
1.35   0.177  0.177   6565   0. 0.  Storable::mretrieve
0.66   0.086  0.086  36878   0. 0.  Date::Simple::_compare
0.58   0.076  0.076   1761   0. 0.  DBD::_::db::prepare_cached
0.46   0.060  0.060  24782   0. 0.  Date::Simple::_add
0.32   0.042  0.042   2900   0. 0.  ELRes::Entity::DESTROY
0.25   0.033  0.033   3700   0. 0.  DBI::common::FETCH
0.18   0.023  0.023   3692   0. 0.  DBI::st::fetch
0.12   0.016  0.016   1756   0. 0.  ELRes::DB::DESTROY
0.08   0.011  0.011   9528   0. 0.  Date::Simple::__ANON__
0.08   0.010  0.010  1   0.0100 0.0100  DynaLoader::bootstrap
0.08   0.010  0.010  2   0.0050 0.0050  DBD::mysql::db::_login

I doubt the ApacheHandler::handler subroutine runs that long, because it 
only shows the accumulated time used by other subroutines it calls. That 
makes the profile isn't really accurate. How do I make it to show the 
statistics of the subroutines called from the handler?


Thank you...

---
Badai Aqrandista
Cheepy (?)




From: "Philip M. Gollucci" <[EMAIL PROTECTED]>
To: Badai Aqrandista <[EMAIL PROTECTED]>
CC: modperl@perl.apache.org
Subject: Re: web application speed problem with OO modules
Date: Mon, 15 Aug 2005 00:32:09 -0400

(I only try to improve the speed of the code, so the use of proxy 
shouldn't be relevant here - I think, I could be wrong).

You might try using

Apache::DProf
and/or
Apache::SmallProf

available here to see where your code is spending its time

http://search.cpan.org/~fwiles/Apache-DB


_
Low rate ANZ MasterCard. Apply now! 
http://clk.atdmt.com/MAU/go/msnnkanz003006mau/direct/01/  Must be over 
18 years.




Re: is there a templating system that....

2005-08-14 Thread jonathan vanasco


I messed around with Templating systems all weekend, and picked a winner

Petal

I wanted to go as simple as possible, and with the help of the list  
narrowed it down to:


HTML::Tree
HTML::Template
Text::TagTemplate
Petal

HTML tree did exactly what I wanted it to, except I remembered as  
much as I know tree structures, working with Nevow's Stan formatting  
I learned to hate them


HTML::Template got ruled out because the only way to get templates to  
render as xhtml valid is to use info as comments

ie:
 isn't valid, but works
 is valid, but doesn't work
 is valid and works,  
but looks cluttered to me


Text::TagTemplate almost worked right:
 <#TAG NAME=VALUE> works, isn't valid
 <#TAG NAME=VALUE/> doesn't work, is valid
 <#TAG NAME=VALUE /> works, is valid (notice the space before  
the close of the tag)
I didn't want to worry about remembering the space.  The author sent  
me a copy of the next version that he will release which,  with a new  
feature, will support what I want...


... But then i realized that the templates work and are valid, but  
don't look nice


Petal templates do look nice, because
Hola, Mundo!
is valid xhtml AND lets you have mockup text that is then replaced

Unfortunately, petal supports all the smart features of tal like if/ 
loops (stuff I didn't want in there), but its ok.  i'll deal.


Thanks to all.


Re: no cookie on redirect : mod_auth_tkt2

2005-08-14 Thread James Smith

Marc,

You will need to get the cookie sent back to the browser,
if you redirect to a URL with no domain in it - Apache
"cleverly" notices this and performs the second request
without going back to the browser. To force return to the
browser include the domain in the URL
  $r->headers_out->set( Location => "http://my.dn.org/login?redirect=1"; );

On Sun, 14 Aug 2005, Marc Lambrichs wrote:

> I'm trying to build a mp2 handler to login using mod_auth_tkt2. I like the 
> idea of probing if
> the client can support cookies, so tried to rebuild it. According to the cgi 
> example there
> is some problem with setting the cookie on a redirect. The same problem - no 
> probe cookie is set
> during the redirect - occurs when I use the following method, and I can't see 
> why.
>
> #-
> sub login: method
> #-
> {
> my ( $class, $r ) = @_;
>
> #$r->print('sub run ', B::Deparse->new->coderef2text( \&run ));
> my $apr = Apache2::Request->new($r);
>
> ### Check if there are any cookies defined
> my $jar = Apache2::Cookie::Jar->new( $r );
> my $cookie = $jar->cookies( 'tkt' );
> my $probe  = $jar->cookies( 'probe' );
> my $has_cookies = $cookie ||
>   $probe  || '';
> if ( ! $has_cookies ){
>### if this is a self redirect warn the user about cookie support
>if ( $apr->param( 'redirect' ) ) {
>   my @remarks = ( 'Your browser does not appear to support cookies.',
>   'This site requires cookies - please turn cookie 
> support' );
>   my $detail = join '&', map { sprintf "detail=%s", $_ } @remarks;
>   $r->internal_redirect_handler( "/error?type=400&$detail" );
>   return Apache2::Const::OK;
>}
>### If no cookies and not a redirect, redirect to self to test cookies.
>else {
>   $cookie = Apache2::Cookie->new( $r,
>   -name   => "probe",
>   -domain => 'my.domain',
>   -value  => 1 );
>   $cookie->path("/");
>   $cookie->bake( $r );
>   $r->headers_out->set( Location => "/login?redirect=1" );
>
>   return Apache2::Const::REDIRECT;
>}
> }
> }
>
>