Chapter 3 Working with Dynamo Web Sites
Working with Web sites
You create and work with Web sites using Sybase
Central. Because PowerDynamo plugs into Sybase Central you can manage
both your databases and your Web sites from within Sybase Central.
What is a Dynamo Web site?
A Dynamo Web site consists of:
- A set of documents stored in a database or in
files on disk, together with a connection specification (including
user ID) for a database.
- A set of data referenced by SQL statements
included in the templates. This data is stored in an ODBC or Open
Client database.
- A set of connections used by the
PowerDynamo Application Server to access the data.
Web site architecture
How documents are stored
Dynamo Web sites include:
- Documents These may be templates, scripts,
or HTML documents.
- Database data The data that fills out queries in
templates.
- Connections To access the data.
Web site documents are usually stored in an
Adaptive Server Enterprise or Adaptive Server Anywhere relational
database in a set of tables. However, the structure of these tables
is hidden from the user by the PowerDynamo application server. Web
sites may also be hosted in the file system.
The data may be contained in an Adaptive Server
Enterprise or Adaptive Server Anywhere database, or in some other
ODBC or Open Client data source.
Hierarchical views of documents
Sybase Central provides a hierarchical view
of a Web site, just like a directory structure. A hierarchical architecture
has advantages for a Web site:
- The URL, the address of documents on the World
Wide Web, uses a hierarchical model. A hierarchical structure is
required for URL access to the documents.
- You can import whole directory trees
of HTML files into a Dynamo Web site database, and maintain hypertext
links from one document to another, as long as these links are coded
as relative addresses, not absolute.
Storing documents on disk
Not all the documents in a site need be held
in a database. Web sites can also contain documents stored in folders
on disk.
For information about creating dynamic file-based
Web sites see "Creating a dynamic
file-based Web site "
For more information about storing documents
on disk and linking these into a database-hosted Web site, see "Linking folders to directories on disk".
Before you begin
You should be familiar with the basics of using
Sybase Central for managing databases. For assistance with using
Sybase Central, see the Sybase Central online help for Dynamo.
Creating a Web site [Adaptive Server Anywhere]
You create Dynamo Web sites from Sybase Central,
the management tool included in Dynamo, Adaptive Server Anywhere,
and Adaptive Server Enterprise.
Web site created at the server
Sybase Central is a client application. You
can use Sybase Central to create a database-hosted Web site on a
database residing anywhere on the network. There is no requirement
for Sybase Central to run on the same machine as the database server.
To create a Web site from Sybase Central [Adaptive
Server Anywhere]:
-
If you do not wish to use an existing
database to hold the Web site, create a database to hold the Web
site. You can do this using the Create Database utility, which is
in the Sybase Adaptive Server Anywhere container in Sybase Central.
For more information about creating a database,
see the Sybase Central online help and "Working with Database
Objects" in the Adaptive Server Anywhere User's
Guide.
-
Start Sybase Central.
-
Create an ODBC data source definition
for this database. Use the ODBC Administrator from the Utilities
folder in Sybase Central.
For more information about creating an ODBC
data source, see "Connecting to a Database" in
the Adaptive Server Anywhere User's Guide.
-
Create a connection profile for your
Web site.
- Select Tools | Connect Profiles.
- Click New. In the Create New Profile
window, enter the name of the profile (this name is used to identify
the Web site in Sybase Central) and select PowerDynamo as the type.
Click OK.
- Fill in the fields in the Connection
Profile window. If you are creating an ODBC connection profile,
you would:
- Select the data source you have created from
the drop-down list of ODBC data sources,
- Enter a valid user ID. Adaptive Server
Anywhere databases are created with a single user, with DBA authority.
The user ID is DBA and the password is SQL.
- When you have filled in all fields,
click OK.
For information on creating File connection
profiles, see "Creating a connection profile for your Web site".
From the Connection Profile window, highlight
the connection profile you just created and click Connect.
If no Web site exists for the user ID
you have specified on the database, Dynamo prompts you to add a
Web site.
- Enter a name for the site. This is the name of
the main contents folder on the site.
- Select the appropriate boxes if you
want to load the PowerDynamo documentation and samples into the
Web site. Click OK to create the site.
To configure this Web site to be accessible
from a Web server, see "Configuring
Web sites".
Notes
- Only one Web site per user can be
created in a database; for example, DBA can create only one Web
site in the sample database. A new user; for example DBA2, can create
another Web site in the same sample database.
- The connection information (database,
user ID, and so on) that you fill in when you first connect to the
Web site serves two functions. It is the owner of the tables containing
the template and script data, and it is provided as a connection
called
<default>
which
can be used for data referenced in queries in templates.
Creating a Web site [Adaptive Server Enterprise]
You create Dynamo Web sites from Sybase Central,
the management tool included with Adaptive Server Enterprise.
Web site created at the server
Sybase Central is a client application. You
can use Sybase Central to create a database-hosted Web site on a
database residing anywhere on the network. There is no requirement
for Sybase Central to run on the same machine as the database server.
To create a Web site from Sybase Central [Adaptive
Server Enterprise]:
-
From Sybase Central, connect to
the Adaptive Server where you want to create the Web site, or create
a new database.
-
Now you need to connect to the database
as a Web site. To do this, you must connect using a Dynamo connection,
not an Adaptive Server Enterprise connection, within Sybase Central.
-
Create a connection profile for your
Web site.
- Select Tools | Connect Profiles.
- Click New.
- In the Create New Profile window,
enter the name of the profile and select PowerDynamo as the type.
Click OK.
- Change the connection type to Open
Client.
- Fill in the fields in the Connection
window:
- Enter a descriptive name in the Connection Name
field, such as My First Site. This name is used to identify the
Web site in Sybase Central. You can use spaces in the name if you
wish.
- Enter the names of the server and
database to connect to. These names are case sensitive.
- Enter a valid user ID and password
for this database. The user ID must have the permissions necessary
to create tables.
- When you have filled in all fields, click OK.
For information on creating ODBC and File
connection profiles, see "Creating a connection profile for your Web site".
Highlight the connection profile you
just created and click Connect.
If no Web site exists for the user ID
you have specified on the database, Dynamo prompts you to add a
Web site.
- Enter a name for the site. This is the name of
the main contents folder on the site.
- Select the appropriate boxes to load
the PowerDynamo documentation and samples into the Web site. Click
OK to create the site.
To configure this Web site to be accessible
from a Web server, see "Configuring
Web sites".
Notes
- Only one Web site per user can be
created in a database; for example, DBA can create only one Web
site in the sample database. A new user; for example, DBA2, can
create another Web site in the same sample database.
- The connection information (database,
user ID, and so on) that you fill in when you first connect to the
Web site serves two functions. It is the owner of the tables containing
the template and script data, and it is provided as a connection
called
<default>
which
can be used for data referenced in queries in templates.
Creating a dynamic file-based Web site
You can use Sybase Central to create a file-based
Web site that resides on any drive that is accessible (locally or
via a network) from the machine where Sybase Central is running.
File-based sites dynamically connect to a database and retrieve
data.
WARNING! | Caution All files in the target directory
will be deleted when creating a dynamic file-based Web site. If
there are read-only files in this directory the Web site will not
be created.
|
To create a file-based Web site from Sybase Central:
-
Create a directory for store your
Web site.
-
From Sybase Central, select Tools | Connect.
-
In the connection profile window:
- Select a connection type of Dynamic
File.
- Enter the name of the connection that you are making.
- Enter the path to the file-based site.
Click OK.
-
If no Web site exists in the directory,
Dynamo prompts you to add a Web site.
-
Select the appropriate boxes to load
the PowerDynamo documentation and samples into the Web site, and
click OK to create the site.
-
To configure this Web site to be accessible
from a Web server, see "Configuring
Web sites".
Notes
WARNING! | Caution File-based Web sites store database
passwords as plain text which makes them accessible through the
file system.
|
Retrieving
data from a database with a dynamic file-based Web site
After you have created a dynamic file-based
Web site, you must create a connection to the database and specify
the connection name in the root folder of the file-based Web site.
To retrieve data from a database:
-
Use Sybase Central to connect
to your file-based Web site.
-
Open the Connections folder of the Web
site.
-
Create a connection to the database you
want to retrieve data.
-
Right-click on the root folder of your
file-based Web site and select Properties.
-
Select the connection that you just created
from the pull down menu of the Connection field.
-
Click OK.
Alternatively, you can create DynaScript connections
in your Web documents to connect to a database and retrieve data.
The following script uses the connection myConn (connects to the
sample database) to execute a SQL query.
<HTML>
<TITLE>testthis.stm</TITLE>
<BODY>
<H1></H1>
<!--SCRIPT
myConn = site.GetConnection("Conn1");
if( myConn == null ) {
myConn = site.CreateConnection("Conn1", "My test connection", "Adaptive Server Anywhere 5.0 Sample", "dba", "sql");
}
-->
<!--SQL CONNECTION_OBJECT=myConn
SELECT contact.last_name, contact.first_name, contact.title
FROM DBA.contact contact
-->
<TABLE BORDER>
<TR>
<TH>last_name</TH>
<TH>first_name</TH>
<TH>title</TH>
</TR>
<!--formatting--><TR>
<TD><!--data--></TD>
<TD><!--data--></TD>
<TD><!--data--></TD>
</TR><!--/formatting-->
</TABLE>
</BODY>
</HTML>
Creating a connection profile for your Web site
You should create a connection profile for
your Web site from Sybase Central. When you create a connection
profile, the connection information is stored in the registry in
encrypted form. This information is used not only in Sybase Central,
but also by the Dynamo application server as database provider profiles.
There are three types of connection profiles
that you may create:
- ODBC connection profile Used for connecting to Adaptive Server Anywhere
or Adaptive Server Enterprise Web sites.
- Open Client connection profile Used for connecting to Adaptive Server Enterprise
Web sites.
- Dynamic File connection profile Used for connecting to Web sites that are hosted
on disk.
Consistency with connections
A Web site should always be connected
to with the same type of connection as was used for the original
creation of the site. For example, if the sample Web site was created
with an ODBC connection, it should not later be connected to with
an Open Client connection
To create a connection profile:
-
From Sybase Central, select Tools | Connection
Profiles. The Connection Profiles window is displayed.
-
Click New. The Create New Profile window
is displayed.
-
Enter a name for the connection profile,
and select PowerDynamo from the list of available types. Click OK.
The Connection window displays.
-
Select a connection type.
- For ODBC:
Fill in the fields
in the Connection window, and click OK to create the profile.
For Open Client:
Enter the name of the
server to which you wish to connect.
Enter the name of the database to which you wish
to connect.
Fill in your user ID and password, and click OK
to create the profile.
For Dynamic File:
Enter the path to the
File-based site, and click OK to create the profile.
The Select Method
When you are creating an ODBC data
source for an Adaptive Server Enterprise database the Select Method
must be set to 0 - Cursor for Dynamo to work. The Select method
setting is located within the ODBC Administrator | ODBC Sybase | Driver
Setup | Performance Tab.
Regenerating a Web site
When you regenerate a Web site, the existing
content of the Web site is deleted, and a new Web site is created.
To regenerate a Web site:
-
With the right mouse button, click
the Web site icon in the left pane of Sybase Central, and select
Regenerate from the menu.
-
Enter a name for the main contents folder
in the Web site setup window, and select the appropriate options
to include the Dynamo documentation and sample application in the
site. Click OK to regenerate a clean Web site.
WARNING! | Caution Regenerating a Web site deletes the
entire content of the Web site. This action cannot be undone.
|
Deleting
a Web site
When you delete a Web site, the existing content
of the Web site is deleted. If the database containing your Web
site has other data, it is not affected by the deletion of the Web
site. Also, the database itself is not deleted.
With the right mouse button, click the Web site icon in the
left pane of Sybase Central, and select Delete from the menu.
WARNING! | Caution Deleting a Web site deletes the entire
content of the Web site. This action cannot be undone.
|
Copyright © 1999 Sybase, Inc. All rights reserved.
|
|