[symfony-users] How to add additional info to cache key for some (not all) actions?

2009-11-28 Thread Mateusz Papiernik
Hi!

Is there any possibility in Symfony (1.2 at that point) to alter cache
key generation algorithm for actions, or supply own cache_key just
like it is possible with partials and components?

I've read how to enable cache with PHP code for particular actions,
and not with static cache.yml, using additional filter. The addCache
method however needs module name, action name and parameters supplied
normally in cache.yml - I'm not sure if I can add something else
there.

I need to make distinct cache entries for a view depending on _which_
user is logged in, and not only if an user is authenticated or not.
With components and partials, I simply supply user_id as an additional
parameter (or include it in sf_cache_key). I have no clue how to
achieve the same thing with actions.

Another case are actions which render different templates depending on
the request type - whether it is typical request, or XMLHttpRequest.
Am I able to make two distinct copies of such an action, or should I
make two distinct actions to enable caching in that situation? Caching
the view now causes trouble, because the XMLHttpRequest AJAX version
returns the wrong template, which was cached before with normal
request to the same action (even though the URLs are different).

I'd be very grateful for any suggestions how to approach actions
caching with need of additional information for cache keys.


Best regards,
Mateusz

--

You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-us...@googlegroups.com.
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en.




[symfony-users] Re: Sf 1.2 route cache problems in prod with sfDoctrineRoute patterns

2009-10-12 Thread Mateusz Papiernik

On Oct 6, 5:52 pm, Mateusz Papiernik  wrote:
> Hi!
>
> I've encountered a strange problem with routing in my symfony 1.2 with
> doctrine application. I tracked it down to routing cache problems.




Anyone? I tried working on it, but basically I'm completely stuck. The
app goes with route cache disabled as for now. I am not sure if it's
really a good way to do things...


My best,
Mateusz Papiernik
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Sf 1.2 route cache problems in prod with sfDoctrineRoute patterns

2009-10-06 Thread Mateusz Papiernik

Hi!

I've encountered a strange problem with routing in my symfony 1.2 with
doctrine application. I tracked it down to routing cache problems.

I have two routes:

user_edit_profile:
  url: /user/:nick/settings
  class:   sfDoctrineRoute
  options: { model: sfGuardUserProfile, type: object }
  param: { module: user, action: settings }
  requirements:
sf_method: [get, post]

user_edit_own_profile:
  url: /user/settings/*
  param: { module: user, action: ownSettings }

The first one enables administrators to easily edit any user profile,
the second one is provided for convenience for an end user.

The action ownSettings is secured in security.yml and looks like that:

public function executeOwnSettings(sfRequest $request) {
  $this->redirect($this->generateUrl("user_edit_profile", $this-
>getUser()->getGuardUser()->getProfile()));
}

The scenario is:

1) I login with an account "maticomp". I go to /user/settings and am
redirected to /user/maticomp/settings.
2) I logout and log in with another account "test". I go to /user/
settings and am redirected to ... /user/maticomp/settings

I modified the action to print some debug information instead of doing
redirects:

public function executeOwnSettings(sfRequest $request) {
  print $this->getUser()->getGuardUser()->getProfile()->getNick() .
"";
  print $this->generateUrl("user_edit_profile", $this->getUser()-
>getGuardUser()->getProfile());
  return sfView::NONE;
}

The result now is:

test
index.php/user/maticomp/settings

After doing "symfony cc" in command line it's:

test
index.php/user/test/settings

The problem is non existent in dev environment (where I guess routing
cache is disabled). It is also non-existent when I disable access to
the directory where route cache is stored (chmod 222 routing).

What could be the possible reason that Symfony caches complete routing
info when objects are passed to sfDoctrineRoute? Maybe I am missing
something here?

I would be very glad for any suggestions how to deal with this
problem.


Thanks in advance,

Best regards,
Mateusz Papiernik

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---