index.shtml revision 742
## -*- coding: utf-8 -*-
##
## CDDL HEADER START
##
## The contents of this file are subject to the terms of the
## Common Development and Distribution License (the "License").
## You may not use this file except in compliance with the License.
##
## You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
## See the License for the specific language governing permissions
## and limitations under the License.
##
## When distributing Covered Code, include this CDDL HEADER in each
## file and include the License file at usr/src/OPENSOLARIS.LICENSE.
## If applicable, add the following below this CDDL HEADER, with the
## fields enclosed by brackets "[]" replaced with your own identifying
## information: Portions Copyright [yyyy] [name of copyright owner]
##
## CDDL HEADER END
##
## Copyright 2008 Sun Microsystems, Inc. All rights reserved.
## Use is subject to license terms.
##
<%!
import os.path
import pkg.server.api as api
import pkg.server.api_errors as api_errors
CLIENT_API_VERSION = 0
%>\
<%page args="g_vars"/>\
<%
base = g_vars["base"]
config = api.ConfigInterface(CLIENT_API_VERSION, base)
request = api.RequestInterface(CLIENT_API_VERSION, base)
# XXX default language if one can't be automatically determined,
# where to set this?
dlang = "en"
# First, get the list of desired languages from the request.
rlangs = request.get_accepted_languages()
# Second, check each language name (which should either be an ISO
# 639(.1/.2) code or an l10n simple name) to see if a directory of
# content exists for it.
for rl in rlangs:
dlang = rl
break
# Third, determine if we need to redirect the user to a particular
# page.
rpath = request.path_info.strip("/")
if rpath == "":
rpath = "index.shtml"
# Finally, redirect the client to the content appropriate for their
# language and region.
raise api_errors.RedirectException("%s/%s" % (dlang, rpath))
%>\