r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[!Cheyenne] Discussions about the Cheyenne Web Server

Dockimbel
2-Jun-2007
[800]
then, if you're not using RT's DB drivers, you need to load your 
driver somewhere : %misc/rsp-init.r or %www/your-app/app-init.r (if 
you've defined a webapp) are good places to do so.
Graham
2-Jun-2007
[801x2]
this is a lot more complicated than the 2005 version :)
so, to send a query to "bugs" ?
Dockimbel
2-Jun-2007
[803x2]
DO-SQL syntax : do-sql [db [word!] data [string! block! word!] /flat]
The RSP engine will do all the opening/closing work for you
Graham
2-Jun-2007
[805x2]
why do you want to close the db connection?
Can't you leave it open all the time?
Dockimbel
2-Jun-2007
[807]
re 2005 version: you're don't need to use do-sql if you don't want 
to. You can do it as usual by opening connection, sending query...closing 
connection. do-sql is just a higher level wrapper to save you some 
time.
Graham
2-Jun-2007
[808x2]
do-sql [ bugs {select * from database} ]   ?
before I just opened the odbc connection when cheyenne started and 
just kept reusing the connection
Dockimbel
2-Jun-2007
[810]
the DB connection is done from one of the bg helper process, so if 
the process quits, it should close the DB connection properly.
Graham
2-Jun-2007
[811]
I c
Dockimbel
2-Jun-2007
[812x3]
nope, I've just copy/paste the do-sql func spec block, sorry for 
being confusing.
do-sql 'bugs "select * from database"
do-sql leaves the DB connection opened until the process quits.
Graham
2-Jun-2007
[815x3]
ahh....
and there's a query object that holds the result of the do-sql ?
I'm looking at the rsp-api.html and don't see anything there
Dockimbel
2-Jun-2007
[818x4]
The "Global Functions" and DB-object cache are not yet documented.
'do-sql returns the resulting recordset
DB-object cache => DB-cache
the current rsp-api doc is just an API reference documentation, I'll 
provide a more general explanation about RSP concepts and features 
separately in a few days.
Graham
2-Jun-2007
[822x2]
Ok. Thanks
Does Cheyenne honor the shebang on rebol cgi scripts ?
Dockimbel
2-Jun-2007
[824]
It just skip it.
Graham
2-Jun-2007
[825x2]
Or, does it just spawn a separate rebol process for it?
Ok, I presumed it wasn't necessary
Dockimbel
2-Jun-2007
[827x2]
Cheyenne uses one of the bg process to execute the CGI.
That way Cheyenne achieve FastCGI speed on normal CGI scripts.
Graham
2-Jun-2007
[829]
Before I think I checked on each page to see if the user was authenticated 
by checking the session.  But it looks like this is now automatic, 
and the user is sent to login page if they access a page and the 
user is not authenticated?
Dockimbel
2-Jun-2007
[830x5]
Right, but only if you're inside a web-app container (defined in 
the config file). Otherwise, it's up to you to do the checking.
You can use RSP at 3 different levels :
1- raw RSP pages : no session data
2- RSP with session context : start a session using SESSION/START 
and keep some data persistant in the session context.
3 - Web-app : RSP application container, automatic session management, 
login state built-in support, etc...
Graham
2-Jun-2007
[835x4]
well, that makes it easier :)
## Error in [conf-parser] : Error in conf file at:
remr odbc://remr !
Hmm.  Doesn't like my database block.
databases [
		remr odbc://remr
]
Dockimbel
2-Jun-2007
[839]
the databases block have to be in : globals [...] specification block
Graham
2-Jun-2007
[840x3]
Ok, now working there.
Should this work?


	in-user: select request/content 'login
	in-pass: select request/content 'pass
	
	if all [ in-user in-pass ][

  result: do-sql 'remr rejoin [ {select staffname from staff where 
  staffname = '} in-user {' and pwd = '} in-pass {'} ]

		print <pre>
		probe result
		print </pre>	
	]
Error Code :  	305
Description : 	script error !

Invalid argument: select staffname from staff where staffname = 'test' 
and pwd = 'letmein'
Near : 	[any [
insert pos/2 data 
copy pos/2
]]
Where : 	do-sql
Dockimbel
2-Jun-2007
[843x3]
if you're using the odbc:// driver, like all RT's DB drivers, it 
requires a : first db-port to open the connection port, so you have 
to change the do-sql source a little bit (in %handler/RSP.r file), 
in do-sql source :
if any [block? pos/2 url? pos/2][
	poke pos 2 open pos/2
]

replace it by :

if any [block? pos/2 url? pos/2][
	poke pos 2 first open pos/2
]
I'll fix that for next release. It wasn't a priority for me until 
now, because I only use my own DB drivers which API differs a little 
from RT's ones.
Graham
2-Jun-2007
[846x3]
Ok.
Error Code :
			
301

		Description :
			
 script  error ! 
 sql needs a value

		Near :
			
[sql: do-sql 'remr qry 
probe
]

		Where :
			
protected-exec
I'm passing a correct sql string .. tested in console, but I get 
this error.
Dockimbel
2-Jun-2007
[849]
need to go, will be back in half a hour.