The Artima Developer Community
Sponsored Link

Python Buzz Forum
Hail Tobor

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ben Last

Posts: 247
Nickname: benlast
Registered: May, 2004

Ben Last is no longer using Python.
Hail Tobor Posted: Jun 17, 2004 6:17 AM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Ben Last.
Original Post: Hail Tobor
Feed Title: The Law Of Unintended Consequences
Feed URL: http://benlast.livejournal.com/data/rss
Feed Description: The Law Of Unintended Consequences
Latest Python Buzz Posts
Latest Python Buzz Posts by Ben Last
Latest Posts From The Law Of Unintended Consequences

Advertisement
A snippet.  A Zope robots.txt, as a Python Script, that returns different values for test and production sites.  Handy if your development site is also open to the rest of the Net.  The date and time are in there so I can see the last time the script ran; I recommend caching these via an AcceleratedHTTPCacheManager.
request = container.REQUEST
RESPONSE =  request.RESPONSE
RESPONSE.setHeader('Content-type','text/plain')

# Return a string identifying this script. host = request.SERVER_URL.lower() if host.startswith('http://'): host = host[7:] print "#Robots.txt for host %s" % host print "#Generated "+str(DateTime())

#This is a list of elements that mark the host as being a #development server.  Edit to put your own in, or set #devServer according to any criteria you please. devMarks=['test','internal'] devServer = False for m in devMarks:   if host.find(m) >= 0:     devServer = True

if devServer:   #running on the development server, request no indexing   #at all.   disallow = "/" else:   #running on the production server,   #allow indexing of everything.   disallow = ""

print "\nUser-agent: *\nDisallow: %s\n" % disallow #Add in prints for global disallows right here.

return printed

Read: Hail Tobor

Topic: I could really use a beer Previous Topic   Next Topic Topic: On the responsibility of running a well-linked website.

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use