Re: [Zope] catching shorter URLs

2007-07-09 Thread Chris Withers

Ken Ara wrote:

Aaron,

The Path Handler product
(http://www.zope.org/Members/NIP/PathHandler) is your
friend. 


Well, it would have been, but it's not necessary nowadays...


Normally, you would create a path handler called
'games' and point it to your display_game method. To
obtain the result you describe, you could move your
display_game code into index_html and test for a
path_to_handle, else display your 'real' index_html.


Nowadays, you can just use a normal python script instead of a path 
handler and process the traverse_subpath...


cheers,

Chris

--
Simplistix - Content Management, Zope & Python Consulting
   - http://www.simplistix.co.uk
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] catching shorter URLs

2007-07-09 Thread Aaron Maupin

Dieter Maurer wrote:

> A "SiteAccess" "AccessRule" can do such things for you.
>
> Look around whether you find some documentation about "AccessRule"s
> and how to tweak the request object in such a rule.

Thanks Dieter!  That indeed did the trick.  It took a lot of digging 
around online (and several times undoing the last edit because it made 
the folder I was working in uneditable with the management interface) 
but in the end I was successful.


For posterity:

A Virtual Host Monster mapping sends any request with the "games" 
subdomain to a special folder with the following access rule:


#

request = context.REQUEST

#determine title (last part of URL)

url = request.other['ACTUAL_URL']
if len(url) > 0:
if url[-1] == '/':
url = url[:-1]
splitpath = url.split('/')
target = splitpath.pop()

#add title as form data to request object

request.form['gametitle'] = target

#rewrite path - display_game is a Python script in the root of
#Zope, so by adding its name to the namestack it will be found.
#Not added if I'm editing the script (hack) so I'm not locked out.

namestack = request.other['TraversalRequestNameStack']

if namestack[0][:6] != 'ZPytho' and namestack[0][:6] != 'manage':
request.other['TraversalRequestNameStack'] = ['display_game']

#

So far it works well.  I can visit

games.mydomain.com/Tetris

and

www.mydomain.com/display_game?gametitle=Tetris

interchangably.

Aaron
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


re: [Zope] catching shorter URLs

2007-07-08 Thread Ken Ara
Aaron,

The Path Handler product
(http://www.zope.org/Members/NIP/PathHandler) is your
friend. 

Normally, you would create a path handler called
'games' and point it to your display_game method. To
obtain the result you describe, you could move your
display_game code into index_html and test for a
path_to_handle, else display your 'real' index_html.

Have fun.

Ken

--- In [EMAIL PROTECTED], Aaron Maupin <[EMAIL PROTECTED]>
wrote:
>
> I'm trying to make pretty URLs for a game site I'm
developing, and due 
> to the hosting environment I'm somewhat limited in
my Apache URL 
> rewrites.  (I've tried the normal mod_proxy /
mod_rewrite rules and they 
> haven't worked in this environment.)
> 
> I'd like the visitors to see
> 
>  http://games.mydomain.com/game-title
> 
> Whereas what's really being accessed is
> 
> 
http://www.mydomain.com/display_game?title=game-title
> 
> or any solution that allows me to query a relational
database for a game 
> title so I don't have to create hundreds of objects
in Zope.
> 
> The only idea I have now is to use a Virtual Host
Monster mapping to 
> send visitors using the games.mydomain.com to a
folder that contains a 
> custom standard_error_message that reads the request
object, figures out 
> the game title, and queries the database but
that's really inelegant.
> 
> Is there a way to inspect the request before Zope
starts traversing objects?
> 
> Or any other ideas on how to accomplish what I want?
 I'm not new to 
> Zope, but I basically use it as a container for
Python scripts and 
> haven't delved too deeply into it otherwise... so I
may be missing 
> something obvious.
> 
> Aaron


   

Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for 
today's economy) at Yahoo! Games.
http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow  
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] catching shorter URLs

2007-07-08 Thread Dieter Maurer
Aaron Maupin wrote at 2007-7-8 11:12 +0900:
>I'm trying to make pretty URLs for a game site I'm developing, and due 
>to the hosting environment I'm somewhat limited in my Apache URL 
>rewrites.  (I've tried the normal mod_proxy / mod_rewrite rules and they 
>haven't worked in this environment.)
>
>I'd like the visitors to see
>
> http://games.mydomain.com/game-title
>
>Whereas what's really being accessed is
>
> http://www.mydomain.com/display_game?title=game-title
>
>or any solution that allows me to query a relational database for a game 
>title so I don't have to create hundreds of objects in Zope.

A "SiteAccess" "AccessRule" can do such things for you.

Look around whether you find some documentation about "AccessRule"s
and how to tweak the request object in such a rule.

If you are unsuccessfull, come back again.
I, personally, will only be able to respond on Thursday
or Friday, however.



-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )