Sharing filters between applications

65 views
Skip to first unread message

Ciaran Archer

unread,
Feb 3, 2012, 8:52:50 AM2/3/12
to Padrino Framework
Hi everyone

I'm wondering if someone can help me with this issue I posted on
StackOverflow?

http://stackoverflow.com/questions/9125772/sharing-filters-between-applications

Thank sin advance,
Ciaran

Davide D'Agostino

unread,
Feb 3, 2012, 9:11:22 AM2/3/12
to pad...@googlegroups.com
Replied

Ciaran Archer

unread,
Feb 3, 2012, 9:58:12 AM2/3/12
to Padrino Framework
Sorry Davide, no luck there, there doesn't seem to be a filters=
method defined on the sub-class.

Here are my Padrino gems:

padrino (0.10.5)
padrino-admin (0.10.5)
padrino-cache (0.10.5)
padrino-core (0.10.5)
padrino-gen (0.10.5)
padrino-helpers (0.10.5)
padrino-mailer (0.10.5)

Thanks!

On Feb 3, 2:11 pm, Davide D'Agostino <daddyez...@gmail.com> wrote:
> Replied
>
> On Feb 3, 2012, at 2:52 PM, Ciaran Archer wrote:
>
>
>
>
>
>
>
> > Hi everyone
>
> > I'm wondering if someone can help me with this issue I posted on
> > StackOverflow?
>
> >http://stackoverflow.com/questions/9125772/sharing-filters-between-ap...
>
> > Thank sin advance,
> > Ciaran

Eleo

unread,
Feb 3, 2012, 3:53:46 PM2/3/12
to pad...@googlegroups.com
Using modules I think would work in theory e.g. `include SharedFilters` in both controller's blocks.  The only gotcha I guess is that the before/after methods are native to Padrino (or Sinatra) so you'd probably want to have the actual filters inside of lambdas or exist within the modules self.included() method.  Optionally the behavior could be methods e.g. `def shared_before`, the only downside being having to call those methods in the filter blocks of all relevant controllers.

I don't have time to hack out an example right now, and I think I'd need to create a test app to determine the implementation details, so if that isn't a good enough clue right now I'll try to provide a working example in the near future.

Padrino controllers aren't class-based so I think going for some type of inheritance is not a good approach; although it might be in Rails.

Ciaran Archer

unread,
Feb 3, 2012, 5:51:34 PM2/3/12
to Padrino Framework


On Feb 3, 8:53 pm, Eleo <sire...@gmail.com> wrote:

>
> Padrino controllers aren't class-based so I think going for some type of
> inheritance is not a good approach; although it might be in Rails.

Thanks Eleo - what other approach can be used to share config and
middleware between apps?

Ciaran Archer

unread,
Feb 6, 2012, 11:44:54 AM2/6/12
to Padrino Framework
Hey Davide, still having some issues with this - but feel the answer
is close! I've updated the SO thread:

http://stackoverflow.com/questions/9125772/sharing-filters-between-applications

I put in the code sample, and all my Rack::Test routes return a 404
for the ClientsApp controller in the example. I take it back out and
all is well.

Cheers,
Ciaran
Reply all
Reply to author
Forward
0 new messages