You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Thomas Lochmatter <so...@lothosoft.ch> on 2004/09/01 11:08:19 UTC

Re: [bug] Apache::FakeRequest::content_languages

You're right: both methods (content_languages() and
content_language()) work on the Apache object, although
only content_languages() is documented (perldoc Apache)!

Since Apache::FakeRequest wants to be a complete fake
object, it should implement both methods as well, I think.
Hence, the patch would be to add content_languages()
instead of replacing content_language().

-- Thomas

Um Fri, 27 Aug 2004 19:25:41 -0700
 schrieb Stas Bekman <st...@stason.org>:
> Thomas Lochmatter wrote:
> > (ModPerl 1.29, Apache.pm 1.27, FakeRequest.pm 1.00)
> > 
> > In the Apache::FakeRequest module, there is a method
> called
> > "content_language". The Apache module however calls
> this
> > method "content_languages".
> > 
> > I guess this is a bug. It could be corrected by
> changing
> > FakeRequest.pm, line 20:
> > <  content content_encoding content_language
> > 
> >> content content_encoding content_languages
> 
> Why do you think it's a bug? there are both
> content_language and content_languages in
> src/modules/perl/Apache.xs:
> 
> char *
> content_language(r, ...)
>      Apache	r
> 
>      CODE:
>      get_set_PVp(r->content_language,r->pool);
> 
>      OUTPUT:
>      RETVAL
> 
> void
> content_languages(r, avrv=Nullsv)
>      Apache	r
>      SV *avrv
> 
>      PREINIT:
>      I32 gimme = GIMME_V;
> 
>      CODE:
>      if(avrv && SvROK(avrv))
>          r->content_languages = avrv2array_header(avrv,
> r->pool);
> 
>      if(gimme != G_VOID)
>          ST(0) = array_header2avrv(r->content_languages);
> 
> -- 
>
__________________________________________________________________
> Stas Bekman            JAm_pH ------> Just Another
> mod_perl Hacker
> http://stason.org/     mod_perl Guide --->
> http://perl.apache.org
> mailto:stas@stason.org http://use.perl.org
> http://apacheweek.com
> http://modperlbook.org http://apache.org
>   http://ticketmaster.com


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [bug] Apache::FakeRequest::content_languages

Posted by William McKee <wi...@knowmad.com>.
On Thu, Sep 02, 2004 at 08:03:01AM -0400, Geoffrey Young wrote:
> you could do both - test-driven development.  personally, I don't know how I
> ever got along without Apache-Test, for both development and debugging.  how
> I wrote applications before seemed insane when compared to using the tools
> we now have available.

+1.

A::T has helped me to write my code, to catch errors that I've introduced
while adding new features, and to do code refactoring (which I've done
quite a bit of as I learn to use Class::DBI). It took me awhile to get
the gist of it (as you can read if you look back in the docs-dev mailling
list) but it was worth the effort. Start with Geoff's article and
skeleton; you'll avoid many of the potholes I hit along the way.


William

-- 
Knowmad Services Inc.
http://www.knowmad.com

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [bug] Apache::FakeRequest::content_languages

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Thomas Lochmatter wrote:
> Thanks for the hint. I didn't know about Apache::Test. It
> seems to be a quite big testing framework.

it can be big or small, depending on what you need it to be :)

> I use Apache::FakeRequest for debugging (while developing)
> rather than for testing. 

you could do both - test-driven development.  personally, I don't know how I
ever got along without Apache-Test, for both development and debugging.  how
I wrote applications before seemed insane when compared to using the tools
we now have available.

> The advantage is that it's very
> simple/small/handy and does exactly what I need: a fake
> Apache object replacement.

sometimes what we think we need it's what we really need ;)

I'd encourage you (and everyone) to give Apache-Test a try.  to kickstart
the adventure, after installing Apache-Test from CPAN you can try plugging
in your module to this skeleton

  http://perl.apache.org/~geoff/Apache-Test-skeleton-mp1.tar.gz

basically, typing 'make test' will start the server in a pristine
environment and run through your test scripts.  and even if you don't (yet)
have test script, you can just 't/TEST -start-httpd' to start apache and
keep it running while you hit against it with a browser.  yeah, that's
pretty much the same as hitting your ordinary dev box, except that you can
isolate the config much easier with Apache-Test, making it possible to add
self-contained tests later.

anyway, HTH

--Geoff

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [bug] Apache::FakeRequest::content_languages

Posted by Thomas Lochmatter <so...@lothosoft.ch>.
Thanks for the hint. I didn't know about Apache::Test. It
seems to be a quite big testing framework.

I use Apache::FakeRequest for debugging (while developing)
rather than for testing. The advantage is that it's very
simple/small/handy and does exactly what I need: a fake
Apache object replacement.

-- Thomas

Um Wed, 01 Sep 2004 13:45:27 -0400
 schrieb Geoffrey Young <ge...@modperlcookbook.org>:
> 
> 
> Thomas Lochmatter wrote:
> > You're right: both methods (content_languages() and
> > content_language()) work on the Apache object, although
> > only content_languages() is documented (perldoc
> Apache)!
> > 
> > Since Apache::FakeRequest wants to be a complete fake
> > object, it should implement both methods as well, I
> think.
> > Hence, the patch would be to add content_languages()
> > instead of replacing content_language().
> 
> FakeRequest is really kinda painful.  is there any reason
> why you aren't
> using Apache-Test to create a live testing environment
> instead?
> 
>   http://search.cpan.org/dist/Apache-Test/
> 
> --Geoff
> 
> -- 
> Report problems: http://perl.apache.org/bugs/
> Mail list info:
> http://perl.apache.org/maillist/modperl.html
> List etiquette:
> http://perl.apache.org/maillist/email-etiquette.html
> 


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [bug] Apache::FakeRequest::content_languages

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Thomas Lochmatter wrote:
> You're right: both methods (content_languages() and
> content_language()) work on the Apache object, although
> only content_languages() is documented (perldoc Apache)!
> 
> Since Apache::FakeRequest wants to be a complete fake
> object, it should implement both methods as well, I think.
> Hence, the patch would be to add content_languages()
> instead of replacing content_language().

FakeRequest is really kinda painful.  is there any reason why you aren't
using Apache-Test to create a live testing environment instead?

  http://search.cpan.org/dist/Apache-Test/

--Geoff

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html