Carl Lerche
2006-Jun-13 02:47 UTC
[Mongrel] mongrel_upload_progress & plugin question in general
Hello,
So, I grabbed the mongrel_upload_progress code from subversion
because I really need something similar for a project I am working
on. Anyway, I installed the gem and can''t figure out a few things.
1) I''m not sure what Upload < GemPlugin::Plugin
"/handlers" is for
2) How to call the Progress < GemPlugin::Plugin "/handlers"
handler.
While I was trying to figure it out, I wrote my own test plugin to
mess around with the general plugin system and what I think it is is
that the handlers aren''t registering with a particular uri. In the
Rdoc for mongrel there is the following code:
require ''mongrel''
class SimpleHandler < Mongrel::HttpHandler
def process(request, response)
response.start(200) do |head,out|
head["Content-Type"] = "text/plain"
out.write("hello!\n")
end
end
end
h = Mongrel::HttpServer.new("0.0.0.0", "3000")
h.register("/test", SimpleHandler.new)
h.register("/files", Mongrel::DirHandler.new("."))
h.run.join
Now, the key thing here is the h.register which associates a uri with
a handler (or the method uri). I don''t see anything like that
happening with the gem plugins. Am I missing something? What would be
the "GemPlugin" way to register a uri with a handler. I''m not
even
sure that it should be associated with the plugin, in which case do I
have to modify mongrel_rails ?
Thanks for any pointers or suggestions on where to look.
-carl
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/mongrel-users/attachments/20060612/fef72159/attachment-0001.htm
Jan Svitok
2006-Jun-13 08:58 UTC
[Mongrel] mongrel_upload_progress & plugin question in general
Hi,
look for documentation for Mongrel::Configurator.
It has method plugin that returns an instance of particular handler:
...
uri ''/whatever'', :handler =>
plugin(''/handlers/progress'', options)
...
if you have
class Progress < GemPlugin::Base ''/handlers''
then
plugin(''/handlers/progress'', options)
is the same as
Progress.new(options)
Then, if you use mongrel_rails, you can use -S switch to insert
additional configuration into
RailsConfigurator, which is a subclass of Mongrel::Configurator
In your script write:
uri ''/whatever'', :handler =>
plugin(''/handlers/progress'', options)
Hope this helps.
What was useful for me to figure this out:
- reading the rdoc for mongrel and gemplugin
- reading the thread on progress plugin on this list
- reading the source of mongrel_rails
- reading the source of another plugin, but I don''t remember which one
it was
Jano
On 6/13/06, Carl Lerche <carl.lerche at verizon.net>
wrote:>
> Hello,
>
> So, I grabbed the mongrel_upload_progress code from subversion because I
> really need something similar for a project I am working on. Anyway, I
> installed the gem and can''t figure out a few things.
>
> 1) I''m not sure what Upload < GemPlugin::Plugin
"/handlers" is for
>
> 2) How to call the Progress < GemPlugin::Plugin "/handlers"
handler.
>
> While I was trying to figure it out, I wrote my own test plugin to mess
> around with the general plugin system and what I think it is is that the
> handlers aren''t registering with a particular uri. In the Rdoc for
mongrel
> there is the following code:
>
> require ''mongrel''
>
> class SimpleHandler < Mongrel::HttpHandler
> def process(request, response)
> response.start(200) do |head,out|
> head["Content-Type"] = "text/plain"
> out.write("hello!\n")
> end
> end
> end
>
> h = Mongrel::HttpServer.new("0.0.0.0", "3000")
> h.register("/test", SimpleHandler.new)
> h.register("/files", Mongrel::DirHandler.new("."))
> h.run.join
>
> Now, the key thing here is the h.register which associates a uri with a
> handler (or the method uri). I don''t see anything like that
happening with
> the gem plugins. Am I missing something? What would be the
"GemPlugin" way
> to register a uri with a handler. I''m not even sure that it should
be
> associated with the plugin, in which case do I have to modify mongrel_rails
> ?
>
> Thanks for any pointers or suggestions on where to look.
>
> -carl
>
>
> _______________________________________________
> Mongrel-users mailing list
> Mongrel-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mongrel-users
>
>