[ic] Usertag return value
emailgrant at gmail.com
Wed Feb 11 20:57:57 UTC 2009
>> >> > but that kills the whole page. What is the correct way to do
>> >> > this so I can evaluate whether or not the tag executed properly?
>> >> You could use exceptions with an Interchange [try] block (see
>> >> etc/log_transaction for an example), but I think a simple return
>> >> value would suffice in this case. If you want a "0" return value
>> >> when one or more of the sizes fails, then use a return value
>> >> variable and only set it to true if all three succeed.
>> > Hey,
>> > Right, there's a bunch of ways to do this, depending on
>> > whether you want to know which one failed (and exit immediately),
>> > or you want to run all three anyway and just indicate the exit
>> > status more as an information than an error.
>> > If you want to exit immediately when one fails, use i.e.:
>> > do_resize(....) or return 0;
>> I'm getting strange results from this now. My usertag is set up like
>> write-file1 or return 0;
>> write-file2 or return 0;
>> write-file3 or return 0;
>> The usertags exits and returns 0, the first 2 write-file commands
>> execute, and none of the chmod-file commands execute. If I remove the
>> "or return 0;" portions, everything executes perfectly. Does that
>> make sense to anyone?
> Check what return value is returned from the write-file commands...
> If they return 0 or undef, then your 'return 0' part will kick in
> and eject even though things were alright.
> Also, for file writing and chmodding you really want to be doing
> proper checking, i.e. logging or printing the value of $! when the
> error happens.
> If you don't know where to begin or what return values come out of
> your write functions, I'd go this way:
> $ret= write-file1;
> $Tag->log("wf1: return=$ret error=$!");
> $ret= chmod-file1;
> $Tag->log("cf1: return=$ret error=$!");
> and so on for all three, and watch your catalog logfile for results...
> Also, you might be able to get rid of chmod if you set a correct umask
> before creating the files.
I'm still not sure why "or return 0;" causes the usertag to fail so I
changed my file writing and chmodding lines like this:
or return 0;
$Tag->log("1: return=$return error=$!");
$return= chmod(0644,"/file/location/".$name."_image.jpg") or return 0;
$Tag->log("2: return=$return error=$!");
and the usertag fails and there is nothing in the catalog error.log.
Can you tell me what I'm doing wrong?
More information about the interchange-users