Re: Form File Uploads

2008-08-27 Thread Bluebie, Jenna
If you're using Camping 2.0 stuff off github, file uploads work  
exactly as they do in regular rack, so search around for rack upload  
examples. :)


In camping 1.5, it works quite similarly, like this:

input.fieldname.tempfile.length #=> how many bytes long it is
input.fieldname[:type] #=> mimetype of upload
input.fieldname.tempfile.read #=> gets you the files contents...  
tempfile will be some kind of an IO object.


I think you can do .filename also, but I don't use it in my projects.

Rack is similar, though at least in builds before Mash got in on the  
action, the syntax was a bit different.

___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list


Form File Uploads

2008-08-27 Thread Josh Schairbaum
Is there a good blog post, article tutorial, anything on doing a file  
upload in Camping?  I've been looking around, but I haven't found  
anything yet.


Regards,
Josh
___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list


Re: File uploads

2008-07-26 Thread Magnus Holm
They havent't changed the method. They probabely should.

When you run Mash.new it transforms all keys to strings (and turns
Hash'es to Mash'es), Mash[] doesn't do anything like that. And it
isn't Mash[:test => 1, :cool => 2] which raises errors, it's when you
call #inspect on it (it tries to sort all the keys).

On Wed, Jul 23, 2008 at 4:49 PM, zimbatm <[EMAIL PROTECTED]> wrote:
> This is curious... why would they change that behavior ?
>
> 2008/7/23 Magnus Holm <[EMAIL PROTECTED]>:
>> Mash[] doesn't work exactly as wanted (if you give it symbols):
>>
>> Mash[:test => 1] #=> 
>> Mash[:test => 1, :cool => 2] #=> Raises error
>>
>> So we have to alias self[] to self.new...
>>
>> On Wed, Jul 23, 2008 at 10:10 AM, zimbatm <[EMAIL PROTECTED]> wrote:
>>> Yum. Did you try just setting YourApp::H = Mash ? If it works like
>>> this out of the box
>>> then we can keep the simpler solution and provide a recipe to work with 
>>> mash ?
>>>
>>> 2008/7/23 Magnus Holm <[EMAIL PROTECTED]>:
 I'm playing with Mash (http://mash-hash.rubyforge.org/) which has some 
 really
 nifty stuff. Here's the branch: 
 http://github.com/judofyr/camping/tree/mash.
 It requires 0.0.6 (which is only on GitHUb), but will work with 0.0.3
 if you drop
 the latest patch.

 I don't know if it's worth another dependency; maybe zimbatm's patch is
 better.

 On Tue, Jul 22, 2008 at 4:40 AM, Bluebie, Jenna
 <[EMAIL PROTECTED]> wrote:
> NoMethodError undefined method `tempfile' for #
> That sure is odd... I guess in Camping 2.0, uploads are not a Camping::H.
> Can we please change Camping::H to output ::H's instead of the original
> value when the original value is_a?(::H)
> That be good. Recursive yumminess. Doesn't solve hashes in arrays, but is
> nice for this and some other things like playing with JSON. :)
> Looks like to do that, we'd need to override Hash#fetch, and maybe Hash#[]
> and stuff... complex, maybe beyond camping scope. Still, I really think
> for consistency file upload hashes in the @input should be ::H's. Maybe 
> not
> put the functionality in ::H, maybe some processing specific to @input.
> Coming right down to it, I'm thinking about putting the functionality in 
> the
> actual Hash class why don't we do that normally? does it cause 
> problems
> with some libraries?
> ___
> Camping-list mailing list
> Camping-list@rubyforge.org
> http://rubyforge.org/mailman/listinfo/camping-list
>



 --
 Magnus Holm
 ___
 Camping-list mailing list
 Camping-list@rubyforge.org
 http://rubyforge.org/mailman/listinfo/camping-list

>>> ___
>>> Camping-list mailing list
>>> Camping-list@rubyforge.org
>>> http://rubyforge.org/mailman/listinfo/camping-list
>>>
>>
>>
>>
>> --
>> Magnus Holm
>> ___
>> Camping-list mailing list
>> Camping-list@rubyforge.org
>> http://rubyforge.org/mailman/listinfo/camping-list
>>
> ___
> Camping-list mailing list
> Camping-list@rubyforge.org
> http://rubyforge.org/mailman/listinfo/camping-list
>



-- 
Magnus Holm
___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list


Re: File uploads

2008-07-23 Thread zimbatm
This is curious... why would they change that behavior ?

2008/7/23 Magnus Holm <[EMAIL PROTECTED]>:
> Mash[] doesn't work exactly as wanted (if you give it symbols):
>
> Mash[:test => 1] #=> 
> Mash[:test => 1, :cool => 2] #=> Raises error
>
> So we have to alias self[] to self.new...
>
> On Wed, Jul 23, 2008 at 10:10 AM, zimbatm <[EMAIL PROTECTED]> wrote:
>> Yum. Did you try just setting YourApp::H = Mash ? If it works like
>> this out of the box
>> then we can keep the simpler solution and provide a recipe to work with mash 
>> ?
>>
>> 2008/7/23 Magnus Holm <[EMAIL PROTECTED]>:
>>> I'm playing with Mash (http://mash-hash.rubyforge.org/) which has some 
>>> really
>>> nifty stuff. Here's the branch: http://github.com/judofyr/camping/tree/mash.
>>> It requires 0.0.6 (which is only on GitHUb), but will work with 0.0.3
>>> if you drop
>>> the latest patch.
>>>
>>> I don't know if it's worth another dependency; maybe zimbatm's patch is
>>> better.
>>>
>>> On Tue, Jul 22, 2008 at 4:40 AM, Bluebie, Jenna
>>> <[EMAIL PROTECTED]> wrote:
 NoMethodError undefined method `tempfile' for #
 That sure is odd... I guess in Camping 2.0, uploads are not a Camping::H.
 Can we please change Camping::H to output ::H's instead of the original
 value when the original value is_a?(::H)
 That be good. Recursive yumminess. Doesn't solve hashes in arrays, but is
 nice for this and some other things like playing with JSON. :)
 Looks like to do that, we'd need to override Hash#fetch, and maybe Hash#[]
 and stuff... complex, maybe beyond camping scope. Still, I really think
 for consistency file upload hashes in the @input should be ::H's. Maybe not
 put the functionality in ::H, maybe some processing specific to @input.
 Coming right down to it, I'm thinking about putting the functionality in 
 the
 actual Hash class why don't we do that normally? does it cause problems
 with some libraries?
 ___
 Camping-list mailing list
 Camping-list@rubyforge.org
 http://rubyforge.org/mailman/listinfo/camping-list

>>>
>>>
>>>
>>> --
>>> Magnus Holm
>>> ___
>>> Camping-list mailing list
>>> Camping-list@rubyforge.org
>>> http://rubyforge.org/mailman/listinfo/camping-list
>>>
>> ___
>> Camping-list mailing list
>> Camping-list@rubyforge.org
>> http://rubyforge.org/mailman/listinfo/camping-list
>>
>
>
>
> --
> Magnus Holm
> ___
> Camping-list mailing list
> Camping-list@rubyforge.org
> http://rubyforge.org/mailman/listinfo/camping-list
>
___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list


Re: File uploads

2008-07-23 Thread Magnus Holm
Mash[] doesn't work exactly as wanted (if you give it symbols):

Mash[:test => 1] #=> 
Mash[:test => 1, :cool => 2] #=> Raises error

So we have to alias self[] to self.new...

On Wed, Jul 23, 2008 at 10:10 AM, zimbatm <[EMAIL PROTECTED]> wrote:
> Yum. Did you try just setting YourApp::H = Mash ? If it works like
> this out of the box
> then we can keep the simpler solution and provide a recipe to work with mash ?
>
> 2008/7/23 Magnus Holm <[EMAIL PROTECTED]>:
>> I'm playing with Mash (http://mash-hash.rubyforge.org/) which has some really
>> nifty stuff. Here's the branch: http://github.com/judofyr/camping/tree/mash.
>> It requires 0.0.6 (which is only on GitHUb), but will work with 0.0.3
>> if you drop
>> the latest patch.
>>
>> I don't know if it's worth another dependency; maybe zimbatm's patch is
>> better.
>>
>> On Tue, Jul 22, 2008 at 4:40 AM, Bluebie, Jenna
>> <[EMAIL PROTECTED]> wrote:
>>> NoMethodError undefined method `tempfile' for #
>>> That sure is odd... I guess in Camping 2.0, uploads are not a Camping::H.
>>> Can we please change Camping::H to output ::H's instead of the original
>>> value when the original value is_a?(::H)
>>> That be good. Recursive yumminess. Doesn't solve hashes in arrays, but is
>>> nice for this and some other things like playing with JSON. :)
>>> Looks like to do that, we'd need to override Hash#fetch, and maybe Hash#[]
>>> and stuff... complex, maybe beyond camping scope. Still, I really think
>>> for consistency file upload hashes in the @input should be ::H's. Maybe not
>>> put the functionality in ::H, maybe some processing specific to @input.
>>> Coming right down to it, I'm thinking about putting the functionality in the
>>> actual Hash class why don't we do that normally? does it cause problems
>>> with some libraries?
>>> ___
>>> Camping-list mailing list
>>> Camping-list@rubyforge.org
>>> http://rubyforge.org/mailman/listinfo/camping-list
>>>
>>
>>
>>
>> --
>> Magnus Holm
>> ___
>> Camping-list mailing list
>> Camping-list@rubyforge.org
>> http://rubyforge.org/mailman/listinfo/camping-list
>>
> ___
> Camping-list mailing list
> Camping-list@rubyforge.org
> http://rubyforge.org/mailman/listinfo/camping-list
>



-- 
Magnus Holm
___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list


Re: File uploads

2008-07-23 Thread zimbatm
Yum. Did you try just setting YourApp::H = Mash ? If it works like
this out of the box
then we can keep the simpler solution and provide a recipe to work with mash ?

2008/7/23 Magnus Holm <[EMAIL PROTECTED]>:
> I'm playing with Mash (http://mash-hash.rubyforge.org/) which has some really
> nifty stuff. Here's the branch: http://github.com/judofyr/camping/tree/mash.
> It requires 0.0.6 (which is only on GitHUb), but will work with 0.0.3
> if you drop
> the latest patch.
>
> I don't know if it's worth another dependency; maybe zimbatm's patch is
> better.
>
> On Tue, Jul 22, 2008 at 4:40 AM, Bluebie, Jenna
> <[EMAIL PROTECTED]> wrote:
>> NoMethodError undefined method `tempfile' for #
>> That sure is odd... I guess in Camping 2.0, uploads are not a Camping::H.
>> Can we please change Camping::H to output ::H's instead of the original
>> value when the original value is_a?(::H)
>> That be good. Recursive yumminess. Doesn't solve hashes in arrays, but is
>> nice for this and some other things like playing with JSON. :)
>> Looks like to do that, we'd need to override Hash#fetch, and maybe Hash#[]
>> and stuff... complex, maybe beyond camping scope. Still, I really think
>> for consistency file upload hashes in the @input should be ::H's. Maybe not
>> put the functionality in ::H, maybe some processing specific to @input.
>> Coming right down to it, I'm thinking about putting the functionality in the
>> actual Hash class why don't we do that normally? does it cause problems
>> with some libraries?
>> ___
>> Camping-list mailing list
>> Camping-list@rubyforge.org
>> http://rubyforge.org/mailman/listinfo/camping-list
>>
>
>
>
> --
> Magnus Holm
> ___
> Camping-list mailing list
> Camping-list@rubyforge.org
> http://rubyforge.org/mailman/listinfo/camping-list
>
___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list


Re: File uploads

2008-07-22 Thread Magnus Holm
I'm playing with Mash (http://mash-hash.rubyforge.org/) which has some really
nifty stuff. Here's the branch: http://github.com/judofyr/camping/tree/mash.
It requires 0.0.6 (which is only on GitHUb), but will work with 0.0.3
if you drop
the latest patch.

I don't know if it's worth another dependency; maybe zimbatm's patch is
better.

On Tue, Jul 22, 2008 at 4:40 AM, Bluebie, Jenna
<[EMAIL PROTECTED]> wrote:
> NoMethodError undefined method `tempfile' for #
> That sure is odd... I guess in Camping 2.0, uploads are not a Camping::H.
> Can we please change Camping::H to output ::H's instead of the original
> value when the original value is_a?(::H)
> That be good. Recursive yumminess. Doesn't solve hashes in arrays, but is
> nice for this and some other things like playing with JSON. :)
> Looks like to do that, we'd need to override Hash#fetch, and maybe Hash#[]
> and stuff... complex, maybe beyond camping scope. Still, I really think
> for consistency file upload hashes in the @input should be ::H's. Maybe not
> put the functionality in ::H, maybe some processing specific to @input.
> Coming right down to it, I'm thinking about putting the functionality in the
> actual Hash class why don't we do that normally? does it cause problems
> with some libraries?
> ___
> Camping-list mailing list
> Camping-list@rubyforge.org
> http://rubyforge.org/mailman/listinfo/camping-list
>



-- 
Magnus Holm
___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list


Re: File uploads

2008-07-22 Thread zimbatm
class H < Hash
# Gets or sets keys in the hash.
#
#   @cookies.my_favorite = :macadamian
#   @cookies.my_favorite
#   => :macadamian
#
def method_missing(m,*a)
x=(m.to_s=~/=$/?self[$`]=a[0]:a==[]?self[m.to_s]:super)
x.kind_of?(Hash) ? H[x] : x
end
undef id, type
  end

2008/7/22 Bluebie, Jenna <[EMAIL PROTECTED]>:
> NoMethodError undefined method `tempfile' for #
> That sure is odd... I guess in Camping 2.0, uploads are not a Camping::H.
> Can we please change Camping::H to output ::H's instead of the original
> value when the original value is_a?(::H)
> That be good. Recursive yumminess. Doesn't solve hashes in arrays, but is
> nice for this and some other things like playing with JSON. :)
> Looks like to do that, we'd need to override Hash#fetch, and maybe Hash#[]
> and stuff... complex, maybe beyond camping scope. Still, I really think
> for consistency file upload hashes in the @input should be ::H's. Maybe not
> put the functionality in ::H, maybe some processing specific to @input.
> Coming right down to it, I'm thinking about putting the functionality in the
> actual Hash class why don't we do that normally? does it cause problems
> with some libraries?
> ___
> Camping-list mailing list
> Camping-list@rubyforge.org
> http://rubyforge.org/mailman/listinfo/camping-list
>
___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list


File uploads

2008-07-21 Thread Bluebie, Jenna

NoMethodError undefined method `tempfile' for #

That sure is odd... I guess in Camping 2.0, uploads are not a  
Camping::H. Can we please change Camping::H to output ::H's instead of  
the original value when the original value is_a?(::H)


That be good. Recursive yumminess. Doesn't solve hashes in arrays, but  
is nice for this and some other things like playing with JSON. :)


Looks like to do that, we'd need to override Hash#fetch, and maybe  
Hash#[] and stuff... complex, maybe beyond camping scope. Still, I  
really think for consistency file upload hashes in the @input should  
be ::H's. Maybe not put the functionality in ::H, maybe some  
processing specific to @input.


Coming right down to it, I'm thinking about putting the functionality  
in the actual Hash class why don't we do that normally? does it  
cause problems with some libraries?___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list