Coldfusion: Access data from another site - coldfusion

I have coldfusion application and currently I am two site under the same folder.
Root
Site 1.
Site1: Application.cfc.
Site 2
Site2: Application.cfc.
Both are using two different sessions.
I want to access a function of Site2 in Site1 but having problems because of the different session.
I had even tried accessing data through scope variable but that also didnt work.
Is there any solution to do this or is it not possible?
Is there any possibility to get name of the application on function. So, that the function can know which application is making the request.
Ex: If function of Site2 get request from Site2 then dont ignore session variable, but ignore if Site1 is making the request

Set up a sub directory in site 2 for external access which handles sessions differently than the root folder of site 2.

Related

Django: application domain causes invalid hyperlinks generation

My django app is accessible under somedomain.com/myappname and that causes lots of trouble. Most of them can be bypassed somehow, but when I found out that I can't access objects managing pages with hyperlinks generated by admin panel (since they should be available under somedomain.com/myappname/admin/etcetc and app generates hyperlinks like somedomain.com/admin/etcetc), I started wondering how to make application understand that its base address is not somedomain.com but somedomain.com/myappname. Is there some config variable I need to set up or anything? Well, the easiest way is to change domain to myappname.somedomain.com, but if only I could do that.

Django redirects app with development site

I have a Django application that exists with complete functionality in both a development and production environment. This is handled by just changing ALLOWED_HOSTS appropriately (assuming you don't want to DEBUG) and setting up Apache to serve each location properly. My issue is that I want to use the Django redirects app to handle my redirects moving forward (a part of this project is a transition away from PHP) because it means I don't need to deal with these redirects in Apache anymore. Redirects are a larger headache and Apache causes issues with its index.php redirect loops. Also this will allow me to transition more website control under Django, which is a goal for management ease. The problem I am encountering is the redirects app uses the SITE_ID to determine a valid target/redirect. The production server has a different hostname than development so I can not test or verify the redirects app. This obviously hurts the purpose of the isolated nearly-identical development server, which is to test all functionality before going live. I understand from the sites framework that individual sites need individual settings.py files and daemons to co-exists, but that again is not helpful to my scenario since the development site is geographically separate from production. It is not clear to me from the documentation:
1) How to add a site, other than adding/altering SITE_ID - where do I choose the associated name?
2) Assuming 1, is that the best way (and is adequate) since I already have a different settings.py file?
3) How did I end up with two sites entries for the same foo.com and how does this affect my redirects? I only have a single wsgi and settings.py (on each server) but
+----+-------------+-------------+
| id | domain | name |
+----+-------------+-------------+
| 1 | example.com | example.com |
| 2 | foo.net | foo.net |
| 3 | foo.net | foo |
+----+-------------+-------------+
in my database? I don't see where these sites are added or configured which is leading to my confusion about how to adjust my sites framework to fit the redirects app. Since I am on Django 1.5.4 the sites framework was enabled by default so I've never even thought about it before.
The name of the associated site does not matter since redirects just uses id, so I deleted all duplicate sites leaving just id 1 for the actual domain name, set SITE_ID = 1 in both production and testing configuration. I do not know where the other sites came from since I only used SITE_ID to set up redirects, but it works now.

SIteCore - multisite - displaying page from wrong site

We have a multisite SiteCore setup with 2 sites within the same .Net solution.
This works by setting the rootPath property on a Site Definition in web.config to limit the site to part of the SiteCore folder structure.
This works well apart from when pages are created with the same name as in the other site then it's serving content from the other site! We have inherited a fair bit of custom code in this solution form the other site so this may be the cause but dont know what Im looking for ...
Thanks
How are you referencing the sites? Do they each have their own host name? Do you have the "hostName" property set for the site node in the Site Defintion?
I will assume that you are not referring to them this way and instead, the sites are using the "virtualFolder" property. If both sites have the same default value of "/" for virtualFolder, attempting to get to either site will result in Sitecore rendering the first site that it matches on, which would be the site listed first.
Try putting the actual site name for "virtualFolder" and "physicalFolder" (e.g. "Site1" and "Site2", respectively). Then you can address your sites as http://yourserver.com/Site1 and http://yourserver.com/Site2. The "virtualFolder" will match first and render the correct site.
See Configuring Sites in the web.config File on SDN for additional information.
Hope this helps.
It turns out this is happening in this case because of a System alias that is redirecting for a subset of pages

Serve media file from Django

I know that it's not a good way to serve directly file and picture from django via views and urls dispatch, but if these files and pictures are served via the server (Apache), the whole world can see them. What if some files and pictures are private for the user, and only the connected user can see these files or pictures? In this case, I need to serve by django itself?
To serve private documents, you should use a Python view that does the security checks.
Here is an example.
If you are using Apache with mod_wsgi then you can use mod_xsendfile
You are essentially looking to run the authorisation for some resources via Django, pass a header back to Apache saying 'Hey dude, lighten up. This user is okay to access this' Apache will then handle returning the resource.
Rough steps (as in, rough enough that you will need to do a little more research using the links I provide as a starting point)
Apache needs to know which resources are public and which aren't. Create a sub directory under media for both of these types (Why not go crazxy and call them /media/public/ and /media/private/)
Set up an alias for the public directory and a WSGIScriptAlias for the protected dir, the protected alias will be pointing to your main site handler (probably django.wsgi)
Add settings to vhost:
XSendFile On
XSendFileAllowAbove On
Add an urlconf to your Django app that handles /media/protected/{whatever} and routes it through your auth Django app auth logic. An example of this is here
A useful snippet for the above is here
and another example for good measure here

Set default location after cflogin

I have a couple web applications written in ColdFusion. The applications have their own folder inside the CF root folder. When I do a successful <cflogin> I am returned to the index page of the root folder. I want the user to stay within that apps folder I know it can be done, I just can't remember how to start. Something where you set the root page for the application withing that App's Application.cfc page. Any insight?
If you delete an Application.cfc from your local drive, that doesn't mean it was deleted from the server. So you might have some hidden Application.cfc's thoughout the App.