creating a drupal non-cached template variable - templates

In drupal 6 I'm trying to execute a function on every page and output a different link based on what IP address someone is coming from. However, when I try this, it seems that the result is getting cached. I have tried this as a module and in template.php, but have not gotten results. What is the best approach to make sure this function executes on every page load? Or is there an easy way to create a template variable that does not get cached?

Is it possible for you to use a block instead with BLOCK_NO_CACHE or BLOCK_CACHE_PER_USER as the block caching policy? If you put a block like this in a region above/below you could achieve a very similar effect on any page you like, node or otherwise.

Related

Cannot specify path variable on a Flow / Send Request

I was playing with Postman Flows, and I was trying to learn by using the Trello API. All requests work on their own if executed manually. I've also debugged values using the terminal to understand where the problem lies. Before that, here's a summary of what I'm doing.
Get all boards for a given trello workspace
For each board, delete that board.
The complete flow looks like this:
I've checked that on the last block Send Request, the looped value of /variable/id outputs the proper board id. I've done this by checking with a terminal block and a string block. I started suspecting that this is caused by a failure of Postman to understand that the variable I'm trying to use is a path variable and not a query parameter. As such I tried to pass a static value to the Send Request and it 404'ed as well (tech aside: in theory for n ids it should give me one 200 and n-1 404s since the variable is static and the board would not be able to be deleted multiple times).
My suspicion comes from the fact that when configuring the block for this request:
You do not get prompted to add the board variable. I've tried to type it in anyway, and even use combinations like :board, with no avail. In fact like I said above, if I use these variables with static values, it still 404s.
ignore the parsing message on the right hand side...
As you can see, board doesn't show up. Did I end up hitting a bug, or is this user error? One thing I do not know how to do, but would help clarify that the issue is that a null value is being passed on to the DELETE would be to output the request itself. On a terminal block I can only see the response.
Thanks in advance.
UPDATE:
After checking the Postman console on the app, I've noticed that in fact the path variable being used is whatever is set on the collection request. It's like it takes the URL as a static field and disregards the path variables. Any thoughts?
Path variables won't be available in your Send Request. Instead, define your path variable with an environment/collection/global variable (i.e. {{board}}) in the value of the path variable. Then it will show up the relevant block of your flow.

django-compressor writing new files in collect_static/CACHE on every request

I've a django website set up using django-compressor + memcached.
Not sure when it started, but I'm finding new css and js files in .../collect_static/CACHE/css and .../collect_static/CACHE/js every minute, like output.2fde5b60eff0.css.
I use django.contrib.staticfiles.storage.ManifestStaticFilesStorage.
I have no clue if this is normal, or happening because of some misconfiguration. But in every few days, I need to clean the server because of this.
Any suggestions what is going on here?
Update: It seems to be happening because of template variables inside css and js code, as per this answer, but as I've a lot of such variables, I still don't know how to fix this.
Ok, so I found the underlying reason.
It is not actually the presence of template variables like {{context_data_var}} within compressed code.
It is the presence of any such variables the values of which change on each request.
I had two such instances:
Storage keys for the third party storage service (such as Google or Amazon)
csrf tokens used in various ajax requests
For 1. above, I simply moved such code outside compress.
For 2., the solution is slightly involved. I had to move away from using {{csrf_token}}. Django explains it in detail here. We need to use the csrftoken cookie instead of the variable {{csrf_token}}, and django sets this cookie if there is at least one {% csrf_token %} in the template. I had one luckily in my base template, so the cookie was already getting set for me. I also had the getCookie() function defined for all pages.
Thus, I was able to get rid of the issue explained in my question.

Salesforce: Can a Javascript Remoting Static Function Access ApexPages.CurrentPage Functions?

I was wondering, In a RemoteAction function in an apex class can or should this be able to access the current force.com site page? I would like to access and write to cookie parameters from within my static remote method but I'm guessing this may not be possible?
If not, any suggestions on how to get around this would be useful.
Thanks in advance.
Remote Action method runs in an.asynchronous mode.Hence accessing values from url parameter will get you null values.If you need any static values for your apex class to process use the parameters.pass from page to your apex method using parameter .
There is one way that i recently discovered to do this
Pass them in from the script on the page using {!$currentpage.parameters.something}
You still need to check for nulls in the code because it might legitimately be null

How to correct from getting Internal Server Error with Joomla

Help
I am working on my joomla! 2.5.6 site and have done something to cause an issue on the front end and the back end.
These are the steps I did to create the issues.
Created a template in Artisteer 4 beta to use as a secondary template, not default.
I tried to delete the template but it told me that I could not delete the last template style.
I used FileZilla FTP to delete that template
The template manager still showed that template in the list.
I read that I had to use the ext manager to delete the template.
I uploaded the template back into a new directory as the same name as the one I previously deleted.
I then deleted the template correctly using the ext manager.
I decided to begin using rt-gantry v3.2.22 as my default template
Now, as I am making mods to this I am constantly met with a 500 Internal Server error. Most times just refreshing the page will take me to the page I wanted and sometimes it takes 2,3,4,5 refreshes to do it.
On the front end after I save a change and refresh the page, I may not see the change unless I refresh it several times. There are some instances that the page displays without any CSS, sometimes it displays with old data. Eventually it will display the saved changes correctly.
How can I find the source of this issue and correct it.
Thanks in advance,
Jeff
url is www.lastingimpressionwebdesign.com
Its a little confusing keeping track of what is or isn't there, but if you're able to get into the admin, then clearly it's a template issue. All the files, of course, need to be there, but there has to be an entry in the jos_extensions table to match them. Also, I'm suspicious of your comment that you're using rt-gantry v3.2.22 as your "template" - that is a framework for templates, not a template itself. You may want to update or re-install Gantry to insure you have a complete installation of it as well.
In short, I'd suggest reverting everything to a standard Joomla template such as Beez, *get the front-end working, and then start gradually adding back your choice in templates with overrides/assignments one step at a time.
It could be the ownership or permissions of your file. It could also be your hosting provider's server environment and how PHP is configured. It's hard to say without looking at the logs.

Are Django template tags cached?

I have gone through the (painful) process of writing a custom template tag for use in Django. It is registered as an inclusion_tag so that it renders a template. However, this tag breaks as soon as I try to change something.
I've tried changing the number of parameters and correspondingly changing the parameters when it's called. It's clear the new tag code isn't being loaded, because an error is thrown stating that there is a mismatch in the number of parameters, and it's evident that it's attempting to call the old function.
The same problem occurs if I try to change the name of the template being rendered and correspondingly change the name of the template on disk. It continues to try to call the old template. I've tried clearing old .pyc files with no luck.
Overall, the system is acting as though it's caching the template tags, likely due to the register command. I have dug through endless threads trying to find out if this is so, but all could find it James Bennett stating here that register doesn't do anything. Please help!
I have gone through the (painful) process of writing a custom template tag for use in Django
I agree that the process for writing the template tag in django is more elaborate than it needs to be.
But let me point you towards some of the third party apps, that when installed, a template tag is just another python function (or class).
http://github.com/alex/django-templatetag-sugar
http://github.com/codysoyland/django-template-repl
Firstly, I can't imagine what's complicated about inclusion tags. Writing a completely custom tag from scratch, yes: that's complicated. But inclusion tags are simply three lines of code and a template - what's complicated about that?
Secondly, all Python code in your Django project is loaded once by the server [*], and remains until it is restarted. The dev server usually detects changes and restarts itself to reload the code, but this doesn't always work. You should get into the habit of checking the console to see that it does restart, and doing it manually if necessary. Note that this has nothing whatsoever to do with caching.
[*] strictly speaking, once per process, but the dev server is single-process anyway.
In case anybody else encounters this: the exact caching mechanism is unclear, but restarting the django dev server fixes the problem.