RE: Is mod_perl the right solution for my GUI dev?
:I would like to continue in the same web front-end : path for more : interactive forms. May be I will have to fight with : Javascript more. : : Yes, much more. But a book I found helpful was 'DHTML : and CSS for the : WWW'. It has helpful examples of various menus and : widgets that can be : accomplished on the web to make an interface richer. While not germane to mod_perl, I did want to add my two cents to this. I did not follow the rest of the thread, so I am not sure in what context you want to deploy a web-site, but be careful with JS and other client-side technologies. IMO, they should be used when they are value-added, but do not become mission critical. In that, they might add some functionality that is useful but not vital for the user to complete the forms or navigate the site. Even in an intranet setting, unless you can positively ensure what browsers are used, you will encounter situations where things just do not work for a certain set of users. When using these technologies, do not be tempted to use browser-specific functions or plug-ins unless you are willing to accept that people will have to use your choice of browser. Follow open standards and rely of server-side solutions as in the end they will save you a lot of headaches and enable you to support the greatest variety of users with the least amount of effort. Good luck! Cheers, Ward
RE: mod_perl/passing session information (MVC related, maybe...)
I am not sure if I follow completely. How do you verify that user who the user says he/she is? I log into your web-site as memberA. You kindly leave me a delicious cookie with my username stored in it. Maybe even my password (I hope not!). Now, I know that another member, memberB, has special rights to your site. What is stopping me from editting the cookie to memberB's username and hijacking their account? And if you do store the password information in the cookie...you are letting each user be compromised either as the cookie is flung through the Internet ether, or minimally on their own computer where someone else can easily access the cookies. With sessionID, you have an ID and information that is checksum'd. We keep that sessionID in a DB once a user has successfully logged in. Whenever I check the sessionID I know they have already logged in -- on top of that, there is no really useful information in the cookie that might compromise security. (Plus, the checksum ensures that one is tampering with the cookie.) But you do keep username, userlevel information within the session information stored on your local DB -- where is reasonably safe from prying eyes. If I wanted to delete a user and ensure they immediately lost all access, it is rather trivial to go through all active sessions in the db, see if the user I am deleting matches the username in the session information, and if so delete the session record. : : * User logs in. : * Site Admin decides to delete the user. : * In our stateless servers, the user_id is invalidated : immediately. : * Next request from User, he's implicitly logged out, : because the user_id :is verified on every request. : : In the case of a session-based server, you have to delete : the user and : invalidate any sessions which the user owns. :
mod_perl/passing session information (MVC related, maybe...)
I was wondering how people are saving state between pages of a session. There is a Apache::Session which is sufficient to check to see if they are logged in, et cetera. But I want to be able to remember the last query so that I can return results into multple pages along with memory of where in the stack I am at. The easiest would to be store the query parameters along with the count information. . .but I do not want to use Apache::Session as I believe that has too much overhead for this sort of thing. There are persistent modules, but I am wondering if there is a better way with Apache and mod_perl -- that ppl have tried and can vouche for its validity. Thanks! Ward
RE: OSC early bird and mod_perl T-Shirts
here is a stretch mod_perl, MODe opPERLtunity mod_perl. one thing you cannot FOO::BAR (but you could (objectively, of course!)) mod perl. scrumpt-diddly-delicious. : -Original Message- : From: Alfred Vahau [mailto:[EMAIL PROTECTED]] : Sent: Tuesday, June 11, 2002 2:54 PM : To: 'mod_perl list' : Subject: Re: OSC early bird and mod_perl T-Shirts : : : May I suggest a camel with the wings of an eagle or a : double humped eagle??? : : The two icons are associated with the two invaluable : references of the Perl : world and somehow the : design must incorporate them. I'm not about to suggest : which creature gets : the prominence. : : Final point: : : I'm 10 hrs ahead of GMT on the other side of the world. : In these hard times, : it's difficult to find a generous sponsor so I won't be : attending the OSC. : But I'd like to have a mod_perl 'T' one day. Please : advice how I could go : about getting one. : : Alfred Vahau : Project Breeeze : SNPS : Uni. PNG : : Gunther Birznieks wrote: : : Maybe this year Randal Schwartz can get his idea : implemented. I think he : had suggested a motto last year that people seemed OK : with but then the : T-Shirts never got done in the end... : : Ah, the annual motto vote... :) Just re-read the same : thread in the : archives last year. : : Later, : Gunther : : At 06:55 PM 6/11/2002, John Bass wrote: : : mod_perl: The camel with wings : : John : : -Original Message- : From: Lupe Christoph [mailto:[EMAIL PROTECTED]] : Sent: 11 June 2002 11:51 : To: Leon Brocard : Cc: mod_perl list : Subject: Re: OSC early bird and mod_perl T-Shirts : : On Tuesday, 2002-06-11 at 10:44:26 +0100, Leon Brocard wrote: : : Yup, I have a designer here who is willing to come : up with something. : Constructive ideas welcome offlist. Better slogans : than modperl: the : only way to fly, modperl: obey your thirst etc. : very welcome too : ;-) : : SCNR: : : Quetzalcoatl: The Feathered Snake :mod_perl: The Feathered Camel : : Profound excuses, : Lupe Christoph : -- : | [EMAIL PROTECTED] | http://www.lupe-christoph.de/ | | I have challenged the entire ISO-9000 quality assurance team to a | | Bat-Leth contest on the holodeck. They will not concern us again. | | http://public.logica.com/~stepneys/joke/klingon.htm | __ Gunther Birznieks ([EMAIL PROTECTED]) eXtropia - The Open Web Technology Company http://www.eXtropia.com/ Office: (65) 64791172 Mobile: (65) 96218290
RE: [OT] MVC soup (was: separating C from V in MVC)
Wow! I kept deleting the MVC Soup mailings wihtout reading...I saw Soup, thought Soap. . .and just deleted. From what I have read thusfar of the archives on MVCyes! I agree. I want to read MORE!!! I have been a practicing wannabe programmer for sometime, and I have been working out the issues of MVC on my own time as a learning experience for mod_perl, sql, html, et cetera. I figured the rest of the world already had all this figured out, and I outta catch up with the curve. The one thing I have been thinking over of recent is my basic templating system. I have content broken into sheets that can be infinately nested through programming the controller. (I am trying to use this new lingo, so I apologize if I mutilate my own words in the process). I have broken the langugae (e.g. English, Japanese, German) into separate config files. Each CGI is a separate application/module that can be added to the main authentication controller (includes restrictions/access to users, user levels (admin/guest/user), and groups of users). Anything worth controlling of any application can be done through TEXT config files. Nothing new here, I think. What I would really like to hear is how people handle their own templating. Is XML'izing (more pointedly XSLT'izing) the process worth the effort? I want to develop a system similar to how AxKit does things. It identifies the user's display, user's preferred language, et cetera and grabs the correct content branch (e.g. html, pdf, wml, text). Any of this can be overridden by the user (e.g. give me this URL as PDF, or send this URL via email to this address). I know that there are a LOT of templating systems out there. . .N+1 for N perl programmers. And there is the issue of data checking/integrity/validation. How abstracted have people made this process, too? Before I babble more than necessary...what about perl.apache.org taking on this whole MVC issue as a part of the site? Like someone else mentioned, we have a lot of tactical information, but little strategic information available. Becauese there are so many ways to do things. . .it can be frustrating. . . since while there are N ways to do it, IMHO there are only n solutions worth considering. And where n N. I would like to get to that n ways before I die. :) Cheers, Ward : -Original Message- : From: Lyle Brooks [mailto:[EMAIL PROTECTED]] : Sent: Friday, June 07, 2002 4:49 PM : To: Bill Moseley : Cc: [EMAIL PROTECTED] : Subject: Re: [OT] MVC soup (was: separating C from V in MVC) : : : Quoting Bill Moseley ([EMAIL PROTECTED]): : I, like many, find these discussion really interesting. : I always wish : there was some write up for the mod_perl site when all : was said and done. : But I guess one of the reasons it's so interesting is : that there's more : than one correct point of view. : : I also find this thread extremely interesting. I didn't : really know : what MVC coding was before reading this thread, or that : by trial and error : what I had coded had gradually evolved to be more : MVC-like, but I'm : really glad this thread came up. : : To me, the eagle book, the guide, and the cookbook all : help produce : great tactical coding techniques, but this discussion : helps fill in a : framework for what I've found somewhat missing to date, : and that is : the employing of strategic coding techniques. : : I wish I had more to offer to the discussion, but I echo Bill's : sentiments that a write-up would be much appreciated and : I hope the : the OT won't take the discussion off list, because I : think it's has : a great bearing on developing quality mod_perl enabled : applications. :
RE: separating C from V in MVC
: Really interesting, xml : appears to be : the final destination for most of us, even if now i : prefer objects. : : Ciao, Valerio That is my big question. Is XML/XSLT really the right solution? Using SAX along with having tags call handlers seems like a pretty powerful way to get a very cool tool to build powerful templating services. I haven't decided if XSLT really is worth the effort as it just seems like a glorified XML (yes; it is indeed) -- what I mean to say, does XSLT really have any real value since everything it does can be done in Perl. If I got make handlers for XSLT, too -- then why even use XSLT? Just go back to plain XML and do it all on my own, no? Part of me wants to go XML as it seems like nearly embraced technology. And having the parsing, et cetera handled by something other my own Perl seems like a good way to remove some headaches and let me get to the job of coding useful things. ;)
RE: Porting to OS X
Wheeler's site provides a lot of great information. When I get to my other computer, I can send you some other useful URLs for setting up UNIX apps on the OS X if you want. I found it took about an evening to install all the software. Another evening to get mod_perl apps up and running, but I had to install XML-related software, too. . .mysql is a snap, too. And I am NOT a sysadmin...not even close. I think it is relatively an easy move, IMHO. Just beaware that the Mac OS filesystem is NOT case-sensitive. Which can cause problems with certain applications. . .and we hope (Apple, you listening?) that they will fix this gross over-sight. Cheers, Ward -Original Message-From: Noam Solomon [mailto:[EMAIL PROTECTED]]Sent: Tuesday, June 04, 2002 10:43 AMTo: [EMAIL PROTECTED]Subject: Porting to OS X Can anyone give me a rough idea how much time it would take to move a server serving mod_perl websites from UNIX to OS X?It usesApache::Session, DBI::Mysql, HTML::Mason,CGI, andApache::OpenIndex, among others, and uses both AuthHandlers and AuthzHandlers. Iknow it's difficult to estimate without knowing how big the websites are, what kind of functions they call, etc., but if you could give me an idea of what kind of problems I can expect to encounter and how difficult they are to work around, I can give a quote to my client. Thanks, Noam Solomon
[SOT] C/F77 Wrapper for Perl
Since I have been unable to use Open3 effectively on my Win32, I am looking for some alternatives. BTW, one of my goals is to make the scripts relatively platform independent -- and therefore I am leaving Open3 and its IPC::Run cousin behind. I have a set of f77 libraries that I know can be compiled on a variety of platforms (Win, UN*X, Mac). For now, I have created an executable on my Win32, whereby it takes STDIN for input and returns results as STDOUT. Is it possible to write a simple C wrapper to the f77 library, and then link to Perl as a module? I have never written a lick of code other than Hello, World!, and I am not looking to be an expert in C. I just want to get the libraries up and functioning. I know this may not be the best place to ask. . .but I thought others might have a fair amount experience with IPC in its many forms. . . ANY HELP IS APPRECIATED! Thanks! Ward
RE: Sharing Variable Across Apache Children
I am desperate enough to use this thread to try to get an answer to my own IPC question. ;) I keep getting the following error using OPEN3 along with the appropriate modifications to my code for using mod_perl with Perl 5.6.1. The offending (and it is very offensive to me!) is: [error] open3: Can't call method close on an undefined value at C:/Perl/lib/IPC/Open3.pm line 327, _GEN_0 line 154. [error] [client 127.0.0.1] [libapreq] remove error on 'C:\WINNT\TEMP\apreq15' Okay, it is two errors. But I am quite positive they are related. I am trying to run this on Win32. When I look at the processes, I found a bunch of abandoned children that I had to kill off. Any ideas? : -Original Message- : From: Sam Tregar [mailto:[EMAIL PROTECTED]] : Sent: Wednesday, April 17, 2002 1:41 PM : To: Perrin Harkins : Cc: [EMAIL PROTECTED]; modperl list : Subject: Re: Sharing Variable Across Apache Children : : : On Wed, 17 Apr 2002, Perrin Harkins wrote: : : Benjamin Elbirt wrote: :Well, lets assume that I were to go with :the shared memory option anyway... what would the : pitfalls be / concerns? : : As mentioned before, you'd probably be better off with : MLDBM::Sync or : Cache::Cache. You can try IPC::Shareable, but a lot of : people seem to : have trouble getting it to work. : : I agree with you 100% - file-based caches are generally : as-fast and far : easier to manage. Still, I can't resist the urge to plug my : IPC::SharedCache module. It's much easier than using : IPC::Shareable (or : even the better alternative, IPC::ShareLite). : : -sam :
OPEN3
I resolved some of my other open3 related errors by undef stdin, etc per the docs. How stdin or stdout have tow references is beyond me, though. For the time being it works, though. Nonetheless, I have getting the following two (related, I assume) errors. I cannot find any docs on these. Anyone have ideas? BTW, when running a command from OPEN3 on Win2k, should the absolute path be UNIX style or DOS style? E.g. /dir1/dir2/prog.exe or c:\dir1\dir2\prog.exe Thanks, Ward [error] open3: Can't call method close on an undefined value at C:/Perl/lib/IPC/Open3.pm line 327, _GEN_0 line 154. [error] [client 127.0.0.1] [libapreq] remove error on 'C:\WINNT\TEMP\apreq15'
Apache::Session suggested mod
Has anyone ever thought to have the table name modifiable? E.g. instead of 'sessions', you could set it to something like 'preferences' for a given instance. I wanted to maintain session information, but also preferences that are attached to a given username. I could just put the two within the same table. . .but as I am anal, I would rather see the data separated. I was thinking of doing it myself -- but thought it might be a worthwhile mod for the entire community. And it saves me maintaining two sets of nearly identical code...and of course, there might be good reasons NOT to do this. Ideas? Thoughts? Cheers, Ward
RE: Open3
I tried the following code submitted by Don, but got the following errors. [Tue Apr 9 16:32:38 2002] nul: untie attempted while 1 inner references still exist at C:/apache/Apache/cgi-lib/FLOE/App/Btops.pm line 101. [Tue Apr 9 16:32:38 2002] nul: untie attempted while 1 inner references still exist at C:/apache/Apache/cgi-lib/FLOE/App/Btops.pm line 102. [Tue Apr 09 16:32:38 2002] [error] open3: Can't call method close on an undefined value at C:/Perl/lib/IPC/Open3.pm line 327. Per UNTIE docs, this occurs when a second reference exits for the tied object. I do not see where, though. Further assistance appreciated! Thanks, Ward P.S. I tried to use IPC::Run, but was unsuccessful. seems flakey on win2k. : -Original Message- : From: Don Hayward [mailto:[EMAIL PROTECTED]] : Sent: Thursday, April 04, 2002 6:28 AM : To: Vuillemot, Ward W : Subject: RE: Open3 : : : Hi Ward -- : : Since Perl5.6 someting like this has been necessary for : Open2 and Open3 : under modperl: : : : : my ($stdin, $stdout, $stderr); : $stdin = tied *STDIN; : $stdout = tied *STDOUT; : $stderr = tied *STDERR; : untie *STDIN; : untie *STDOUT; : untie *STDERR; : use FileHandle; : my $Reader = new FileHandle; : my $Writer = new FileHandle; : my $ERR = new Filehandle; : use IPC::Open3; : my $pid = open3( \*Writer,\*Reader, \*ERR, somescript); : unless ($pid) { print open3 failed\n,$c-end_html; exit; } : Writer-autoflush(); : . : . : . : print Writer $stuff\n; : my $ret = Reader; : . : . : . : tie *STDIN, ref $stdin, $stdin; : tie *STDOUT, ref $stdout, $stdout; : tie *STDERR, ref $stderr, $stderr; : : : On Wed, 3 Apr 2002, Vuillemot, Ward W wrote: : : Since we are on the topic...and before some says it is : WOT, I wanted to ask : a corollary question. : : I wrote a simple script to use Open2 as a means of : interacting with some : FORTRAN programs I have. I wanted to create pre and : post-processing using : PERL and leave the numerical stuff (and tons of legacy : code) to the FORTRAN. : Anyway, the Perl script from a command prompt works -- it sends : pre-processed data as STDIN and catches the processed : data from STDOUT : without a hitch. The moment I try it running Apache : 1.33, Perl 5.6.1, : latest version of Open2, and mod_perl the thing just : ties up all the : computer's resources. : : If I could get it to work then I would be a LONG WAY to : really altering the : way we do things at work. : : I have read what docs there are with Perl for this. . : .but I am wondering if : there are any caveats that I should be aware from using : a web-server to : initiate the commands. Or is there an alternative : method I might explore? : : thanks! : Ward : : : -Original Message- : : From: Rasoul Hajikhani [mailto:[EMAIL PROTECTED]] : : Sent: Wednesday, April 03, 2002 1:54 PM : : To: Elizabeth Mattijsen : : Cc: [EMAIL PROTECTED] : : Subject: Re: Open3 : : : : : : Elizabeth Mattijsen wrote: : : : : At 01:44 PM 4/3/02 -0800, Rasoul Hajikhani wrote: : : Hello folks, : : I am writing a web based interface to gpg and am using : : IPC::Open3 and : : IO::Select to manage STDIN, STDOUT and STDERR handles. : : But, I can not : : get stdin to work properly. Here is my code: : : I am using perl 5.053 and Apache/1.3.14 Ben-SSL/1.42 : : (Unix) PHP/4.0.3pl1 : : mod_perl/1.24_01. : : Can anyone see what am I doing wrong? : : : : Make sure your IPC::Open3 is up-to-date. If it is the : : version that came : : with Perl 5.053, it probably has a bug in it. I : : remember having to patch : : it waaay back (like 5 years ago) to get it to : work properly... : : : : Elizabeth Mattijsen : : : : My IPC::Open3 is OK. My problem is with IO::Select. Does : : anyone know : : whether IO::Select has any bugs? I have read the man : : pages and looked : : through the Perl Cook Book for a code snipet that would : : use IO::Select : : to write to STDIN. The one that is in the book does not : : work for me. So : : any comments/suggestions? : : Thanks in advance : : -r : : : : : Don Hayward [EMAIL PROTECTED] : Mote Marine LaboratoryVoice: 941.388.4441 : Cell
RE: Open3
Since we are on the topic...and before some says it is WOT, I wanted to ask a corollary question. I wrote a simple script to use Open2 as a means of interacting with some FORTRAN programs I have. I wanted to create pre and post-processing using PERL and leave the numerical stuff (and tons of legacy code) to the FORTRAN. Anyway, the Perl script from a command prompt works -- it sends pre-processed data as STDIN and catches the processed data from STDOUT without a hitch. The moment I try it running Apache 1.33, Perl 5.6.1, latest version of Open2, and mod_perl the thing just ties up all the computer's resources. If I could get it to work then I would be a LONG WAY to really altering the way we do things at work. I have read what docs there are with Perl for this. . .but I am wondering if there are any caveats that I should be aware from using a web-server to initiate the commands. Or is there an alternative method I might explore? thanks! Ward : -Original Message- : From: Rasoul Hajikhani [mailto:[EMAIL PROTECTED]] : Sent: Wednesday, April 03, 2002 1:54 PM : To: Elizabeth Mattijsen : Cc: [EMAIL PROTECTED] : Subject: Re: Open3 : : : Elizabeth Mattijsen wrote: : : At 01:44 PM 4/3/02 -0800, Rasoul Hajikhani wrote: : Hello folks, : I am writing a web based interface to gpg and am using : IPC::Open3 and : IO::Select to manage STDIN, STDOUT and STDERR handles. : But, I can not : get stdin to work properly. Here is my code: : I am using perl 5.053 and Apache/1.3.14 Ben-SSL/1.42 : (Unix) PHP/4.0.3pl1 : mod_perl/1.24_01. : Can anyone see what am I doing wrong? : : Make sure your IPC::Open3 is up-to-date. If it is the : version that came : with Perl 5.053, it probably has a bug in it. I : remember having to patch : it waaay back (like 5 years ago) to get it to work properly... : : Elizabeth Mattijsen : : My IPC::Open3 is OK. My problem is with IO::Select. Does : anyone know : whether IO::Select has any bugs? I have read the man : pages and looked : through the Perl Cook Book for a code snipet that would : use IO::Select : to write to STDIN. The one that is in the book does not : work for me. So : any comments/suggestions? : Thanks in advance : -r :
RE: Asia To USA Shipping Rates
Not to beat a dead horse...but we all can have an impact on these guys. Write a VERY pointed email explaining your position as a web developer. If you do contracting work, convince the company that you _will_ never use their product, nor suggest it to any of your *many* customers. . .and will further go to any pains to direct traffic to their competitors. Period. we are the ones with the power. . .we are the GEEKS! And the NERDS! I mean those two words in the best of light, with the greatest of respect and pride. :D Cheers, Ward : -Original Message- : From: Ask Bjoern Hansen [mailto:[EMAIL PROTECTED]] : Sent: Saturday, March 23, 2002 2:14 AM : To: Geoffrey Young : Cc: [EMAIL PROTECTED] : Subject: Re: Asia To USA Shipping Rates : : : On Mon, 18 Mar 2002, Geoffrey Young wrote: : : [EMAIL PROTECTED] wrote: : :We have a full collection of wholesale freight rate : calculators at : : Aaaahhh!! Ask, anybody, make it stop!!! : : Wow. The lusers had actually subscribed that address to : be able to : post. : : I'll do what I can to make it stop. : : - ask :
RE: mod_perl does not see multipart POSTs
I tried the code. Still nothing. I did turn On PerlWarn in httpd.conf. Upon restart I saw the following: errorlog [Wed Mar 20 07:55:19 2002] [info] master_main: Restart event signaled. Doing a graceful restart. defined(@array) is deprecated at C:/Perl/site/lib/Apache/DBI.pm line 135. (Maybe you should just omit the defined()?) [Wed Mar 20 07:55:21 2002] [info] Parent: Created child process 2936 [Wed Mar 20 07:55:21 2002] [info] Parent: Duplicating socket 244 and sending it to child process 2936 [Wed Mar 20 07:55:22 2002] [info] BytesRead = 372 WSAProtocolInfo = 2006620 [Wed Mar 20 07:55:26 2002] nul: Use of uninitialized value in subroutine entry at C:/Perl/site/lib/Apache.pm line 61. /errorlog I am not sure where the Apache::DBI error crept in, but I believe it is unrelated. As for line 61 of Apache, I do not know if this is a warning I can ignore or not. Also, as for not using parse() -- it was my understanding it was not necessary to call explicitly, however you could use the status to provide some error catching. . . Is there a bare-bones httpd.conf file I can use to run mod_perl? I am presuming it is my configuration of Apache that might be causing problems. I have the latest mod_perl, apache modules, and apache that I am aware of. completely befuddled now. :| Thanks, Ward : -Original Message- : From: Randy Kobes [mailto:[EMAIL PROTECTED]] : Sent: Tuesday, March 19, 2002 9:24 PM : To: Vuillemot, Ward W : Cc: 'Issac Goldstand'; [EMAIL PROTECTED] : Subject: Re: mod_perl does not see multipart POSTs : : : : - Original Message - : From: Vuillemot, Ward W [EMAIL PROTECTED] : To: 'Issac Goldstand' [EMAIL PROTECTED]; : [EMAIL PROTECTED] : Sent: Tuesday, March 19, 2002 2:30 PM : Subject: RE: mod_perl does not see multipart POSTs : : : I simplified everything to the bare bones. Nothing is : getting passed. I : am : at a complete loss. If anyone has a few minutes, just : try running this. : You should be able to point it toward a text/plain file : and have it : displayed below the file upload form. : : I'm not quite sure what the full requirements are, but : the following : works for me in displaying the contents of the uploaded : file - this : is on Win32 with the latest mod_perl/libapreq packages. : : In httpd.conf: : ** : PerlModule Apache::testUpload : Location /testUpload :SetHandler perl-script :PerlHandler Apache::testUpload :PerlSendHeader Off : /Location : ** : and Apache/testUpload.pm is : : package Apache::testUpload; : use strict; : ## : ### START LOADING MODULES ### : ## : use Apache::Request (); : use CGI; : use Apache::Constants qw(:common); : ## : ### HANDLER### : ## : sub handler{ :my $q = Apache::Request-new(shift, DISABLE_UPLOADS = 0, :POST_MAX = 2048); :return main($q); : } : : ## : ### START OF MAIN LOGIC ### : ## : sub main{ :my $q = shift; :my $status = $q-parse(); :return $status unless $status == OK; :my %results = (); :my $cgi = CGI-new(); :# :## START FORM ## :# :$results{content} .= $cgi-start_multipart_form; :$results{content} .= $cgi-filefield(-name='uploaded_file', : -default='starting value', : -size=50, : -maxlength=80); :$results{content} .= $cgi-submit(); :$results{content} .= $cgi-endform; :# :## START UPLOAD FILE ## :# :my $upload = $q-upload || undef; :if ($upload) { : my $fh = $upload-fh; : my $filename = $upload-filename; : my $size = $upload-size; : $results{content} .= Upload Filebr /; : $results{content} .= Filename: $filenamebr /; : $results{content} .= Size: $sizebr /; : $results{content} .= $_br / while $fh; :} :# :## START OUTPUT## :# :# send results to browser :$q-send_http_header('text/html'); :print $cgi-start_html('File Upload Test'); :print $cgi-h1('Content') . $results{content}; :print $cgi-end_html(); :return OK; : } : 1; : ** : : Apart from abbreviating the output
RE: mod_perl does not see multipart POSTs -- SOLVED
Using the POST2GET snippet was interferring. I thought I had turned it off when trying Lergon's suggestion. I must not have. As for the actual code. . .I copied it exactly as Lergon's and it works. I know what was different, but I swear that what I had was taken verbatim from mod_perl documentation. Just for academic purposes. I had something like sub handler{ use Apache::Constants qw(:common); my $r = Apache-request(shift); main($r); return OK; } sub main{ my $r = shift; my $q = Apache::Request-new(shift, DISABLE_UPLOADS = 0, POST_MAX = 204800); blah blah blah } Per Lergon's code I just simplified it to sub handler{ use Apache::Constants qw(:common); my $q = Apache::Request-new(shift, DISABLE_UPLOADS = 0, POST_MAX = 204800); main($q); return OK; } sub main{ my $q = shift; blah blah blah } To boot, I was using the POST2GET module found at http://perl.apache.org/guide/snippets.html#Reusing_Data_from_POST_request Once I got rid of POST2GET and simplified the script ala Lergon's code things started to work. Sigh. However, I followed code snippets from http://perl.apache.org/guide/porting.html#Converting_into_Perl_Content_Han I guess I either did not read things carefully, or I am missing something. :( I would imagine I had about 3 solutions going at once -- that is to say that if any one of them were implemented alone things might have worked. In conjunction with each other they fumbled each other up. Oh well. I do appreciate everyone's time. Hopefully the above information might prove useful to other people in similar situation. Cheers, Ward : -Original Message- : From: Ernest Lergon [mailto:[EMAIL PROTECTED]] : Sent: Tuesday, March 19, 2002 1:30 PM : To: [EMAIL PROTECTED] : Subject: Re: mod_perl does not see multipart POSTs : : : Vuillemot, Ward W wrote: : : Here is the Apache config : PerlModule testUpload : Location /testUpload : SetHandler perl-script : PerlHandler testUpload : PerlSendHeader Off : # limit POSTS so that they get processed properly : Limit POST : PerlInitHandler POST2GET : /Limit : /Location : : : Hi Ward, : : assumed, you have seen the example from : : http://perl.apache.org/guide/snippets.html#Reusing_Data_fr : om_POST_request : : and you have written your own POST2GET.pm, more questions : are arising: : : Is POST2GET.pm loaded anywhere - in a startup.pl or via : httpd.conf? : : Some more hints: : : Add 'use warnings;' to your code and look at your error_log. : CGI.pm should be loaded AND compiled very early. : Be careful with global vars under mod_perl. : Look in CPAN to avoid reinventing the wheel: : http://search.cpan.org/search?mode=modulequery=upload : : Ernest : : : : -- : : ** : *** : * VIRTUALITAS Inc. * :* : ** :* : * European Consultant Office * http://www.virtualitas.net * * Internationales Handelszentrum * contact:Ernest Lergon * * Friedrichstraße 95 *mailto:[EMAIL PROTECTED] * * 10117 Berlin / Germany * ums:+49180528132130266 * *
RE: mod_perl does not see multipart POSTs -- SOLVED
Randy, My apologies! Thank you for the code. Ernest, Thanks for the clues! You take your namesake seriously, too. Wonderful! ;) Cheers, Ward
RE: mod_perl does not see multipart POSTs
I simplified everything to the bare bones. Nothing is getting passed. I am at a complete loss. If anyone has a few minutes, just try running this. You should be able to point it toward a text/plain file and have it displayed below the file upload form. No matter what I do, all I am seeing for content_type is: CONTENT_TYPE: multipart/form-data; boundary=---7d2fb231407ee ie, nothing. Here is the Apache config PerlModule testUpload Location /testUpload SetHandler perl-script PerlHandler testUpload PerlSendHeader Off # limit POSTS so that they get processed properly Limit POST PerlInitHandler POST2GET /Limit /Location Here is the code: package testUpload; use strict; our %results; our %messages; ## ### START LOADING MODULES ### ## use Apache::Request (); ## ### HANDLER### ## sub handler{ use Apache; use Apache::Constants qw(:common); my $r = shift; Apache-request($r); main($r); return OK; } ## ### START OF MAIN LOGIC ### ## sub main{ my $r = shift; my $q = Apache::Request-new($r, DISABLE_UPLOADS = 0, POST_MAX = 2048); my $cgi = CGI-new(); # ## START FORM ## # $results{content} .= $cgi-start_multipart_form; $results{content} .= $cgi-filefield(-name='uploaded_file', -default='starting value', -size=50, -maxlength=80); $results{content} .= $cgi-submit(); $results{content} .= $cgi-endform; # ## START UPLOAD FILE ## # my $upload = $q-upload || undef; my $fh = ( defined($upload) ? $upload-fh : undef ); $results{content} .= Upload Filebr /; if (defined( $fh )) { while ($fh) { $results{content} .= $_; } } # ## START DEBUG ## # foreach my $var (sort keys %ENV) { push(@{$messages{debug}},( $var: $ENV{$var} )) if ($var =~ /content/i); } foreach my $var ($q-param) { push(@{$messages{debug}},( $var: .$q-param($var) )) if $var; } # ##START MESSAGES ## # # generate messages and/or errors if any foreach my $type (keys %messages) { my $status = join($cgi-p,@{$messages{$type}}) if $messages{$type}; $results{contenterrata} .= $status if $status; } # ## START OUTPUT## # # send results to browser $r-send_http_header('text/html'); print $cgi-start_html('File Upload Test'); print $cgi-h1('Content') . $results{content}; print $cgi-h1('Errata') . $results{contenterrata}; print $cgi-end_html(); # clean up for mod_perl %results = (); %messages = (); } 1; : -Original Message- : From: Issac Goldstand [mailto:[EMAIL PROTECTED]] : Sent: Monday, March 18, 2002 9:37 AM : To: Vuillemot, Ward W : Cc: [EMAIL PROTECTED] : Subject: Re: mod_perl does not see multipart POSTs : : : I'm not sure I understand what you're asking... Apache, : on it's own, : does not support any internal parsing of POST data, multipart or : otherwise, so why should mod_perl? For this, we have the : Apache::Request library in mod_perl (Which is the : mod_perl interface to : the libapreq library for Apache's C API). libapreq supports : multipart/form-data, even without a file upload... : : Issac : : Vuillemot, Ward W wrote: : : All, : : I am still trying to figure out why my setup of mod_perl : does not have : multipart POSTs. I rebooted my machine, and found that, : whereas I reported : before mod_perl would try to reload the page (which it : should not but send : out a text/plain attachment for download), it appears : the script (running as : a perl handler) does not see any of the multipart POST. : Vanilla posts are : not a problem, though. Even if the information being : sent via multipart is : _not_ a file to upload to the server, the information is : lost in transit. : : Here is what is odd. : : The same scripts/modules unmodified and running as : perl_cgi are okay. : Multipart forms allow me to upload files, et
RE: mod_perl does not see multipart POSTs
Just to re-iterate a previous post. Here is what I have done thusfar. My httpd.conf file: # # ** # ** MOD PERL CHANGES ** # ** # limit POSTS so that they get processed properly Limit POST PerlInitHandler POST2GET /Limit # force reloading of modules on restart PerlFreshRestart on # Perl module primitive mother load on start/restart #PerlRequire lib/perl/startup.pl # FLOE application (mod_perl) PerlModule Apache::DBI PerlModule floeApp Location /floeApp SetHandler perl-script PerlHandler floeApp PerlSendHeader On /Location And the relevant two snippets of code from the script are: ## process incoming # if submitted my %hash = undef; my $initialList = $q-param('initialList') || ''; my $upload = $q-upload || undef; my $fh = $upload-fh if defined($upload); if (defined($upload) $upload) { $initialList = ''; while ($fh) { $initialList .= $_; } } ## some processing is done to the POST'ed data ## and eventually. . . ## send file to client print Content-type: text/plain\n; print Content-Disposition: attachment; filename=list.txt\n\n; foreach my $value (sort keys %$hash) { chomp($value); next unless ($value); print $hash-{$value}$CRLF$value$CRLF; } exit; $q is the Apache::Request object. When running in CGI mode it is simply pointing toward the CGI.pm object. I did not mean to presume Apache was doing anything to anything. Apache::Request does not seem to appear to support/handle multipart in my present config. I do not know why. All I have changed in my code is to use Apache::Request instead of CGI. Otherwise, the scripts are untouched. Same machine, same httpd.conf other the mod_perl changes, same scripts. . . .then why cannot I not see anything being passed via multipart/form-data encoding? : -Original Message- : From: Issac Goldstand [mailto:[EMAIL PROTECTED]] : Sent: Monday, March 18, 2002 9:37 AM : To: Vuillemot, Ward W : Cc: [EMAIL PROTECTED] : Subject: Re: mod_perl does not see multipart POSTs : : : I'm not sure I understand what you're asking... Apache, : on it's own, : does not support any internal parsing of POST data, multipart or : otherwise, so why should mod_perl? For this, we have the : Apache::Request library in mod_perl (Which is the : mod_perl interface to : the libapreq library for Apache's C API). libapreq supports : multipart/form-data, even without a file upload... : : Issac : : Vuillemot, Ward W wrote: : : All, : : I am still trying to figure out why my setup of mod_perl : does not have : multipart POSTs. I rebooted my machine, and found that, : whereas I reported : before mod_perl would try to reload the page (which it : should not but send : out a text/plain attachment for download), it appears : the script (running as : a perl handler) does not see any of the multipart POST. : Vanilla posts are : not a problem, though. Even if the information being : sent via multipart is : _not_ a file to upload to the server, the information is : lost in transit. : : Here is what is odd. : : The same scripts/modules unmodified and running as : perl_cgi are okay. : Multipart forms allow me to upload files, et cetera. In : short, I am : confident the problem is not with my programming. : : I am using the code snippet, POST2GET, to capture the : one-time read of POST : and storing as if it was retrieved via GET. : : Any ideas how to debug this? : : I REALLY REALLY would love some feedback. I would love : to think that all my : effort to stay away from M$ ASP are worth it -- esp. : when I stand up to : defend Perl, Apache, and mod_perl in an environment that : is decidely : M$-bent. : : Thanks! : Ward : : : :
POST and multipart/data-form question
I have searched off and on for the past 3 weeks for a solution to my problem. I am at wits end. . .and thought I would finally ask the mailinglist. I had a set of CGI scripts that worked without problem. I began the process about 4 weeks ago of moving them to mod_perl. The suite of scripts are handled as their own perlHandler collection. One of the scripts has a form where a user can either enter data directly, or indicate a file of equivalent data. When I use the form to POST without any enctype and if you enter directly into the form things work correctly. That is, the data is massaged and sent back to you as downloadable file. Of course, this form does not handle file uploads. Now, I change nothing more than the form enctype to multipart/data-form. Now, regardless of how the data is presented in the form (e.g. directly or via file upload) the browser tries to refresh the screen with the web-page (which it should not since its only response is to send to the client a file to download). However, the web page does not get completely sent, and consistently stops in the middle of the send. I have been using the POST2GET snippet to help make the post more persistent. In short, my httpd.conf file looks like: # # ** # ** MOD PERL CHANGES ** # ** # limit POSTS so that they get processed properly Limit POST PerlInitHandler POST2GET /Limit # force reloading of modules on restart PerlFreshRestart on # Perl module primitive mother load on start/restart #PerlRequire lib/perl/startup.pl # FLOE application (mod_perl) PerlModule Apache::DBI PerlModule floeApp Location /floeApp SetHandler perl-script PerlHandler floeApp PerlSendHeader On /Location And the relevant two snippets of code from the script are: ## process incoming # if submitted my %hash = undef; my $initialList = $q-param('initialList') || ''; my $upload = $q-upload || undef; my $fh = $upload-fh if defined($upload); if (defined($upload) $upload) { $initialList = ''; while ($fh) { $initialList .= $_; } } ## some processing is done to the POST'ed data ## and eventually. . . ## send file to client print Content-type: text/plain\n; print Content-Disposition: attachment; filename=list.txt\n\n; foreach my $value (sort keys %$hash) { chomp($value); next unless ($value); print $hash-{$value}$CRLF$value$CRLF; } exit; Any ideas? I would love to get this solved so I can get back to developing useful scripts. :) Thanks! Ward Ward W. Vuillemot Boeing Flight Operations Engineering Performance Software tel +01 206-662-8667 * fax +01 206-662-7612 [EMAIL PROTECTED]
RE: POST and multipart/data-form question
not a type -- just my brain switching things. the form is correct. : -Original Message- : From: Robin Berjon [mailto:[EMAIL PROTECTED]] : Sent: Thursday, March 14, 2002 8:22 AM : To: [EMAIL PROTECTED] : Subject: Re: POST and multipart/data-form question : : : On Thursday 14 March 2002 17:12, Vuillemot, Ward W wrote: : Now, I change nothing more than the form enctype to : multipart/data-form. : : I haven't looked at your sample code in detail, but as : someone that got : caught on similar problems due to silly typoes I'd like : to point out that : it's multipart/form-data and not the other way 'round. : : -- : __ : _ : Robin Berjon [EMAIL PROTECTED] -- CTO : k n o w s c a p e : // venture knowledge agency www.knowscape.com : -- : - : There's too much blood in my caffeine system. :