Poesia

 
 05 Sep 2010 @ 9:31 PM 

Este post es para escribir esta poesia que es casi declarativa.

tomado de

http://www.beardygeek.com/2010/09/python-decorators-for-djangonauts/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+BeardyGeek+(BeardyGeek.com)

 

from urlparse import urlparse
from django.http import HttpResponseRedirect

def refer_check(func):
    def decorate(request):
        referer = request.META.get('HTTP_REFERER', '')

        if referer == 'http://www.example.com':
            return func(request)
        else:
            return HttpResponseRedirect('/')
    return decorate

 

 

@refer_check
def my_view(request):
    ....
    return render_to_response('myview.html')

Posted By: admin
Last Edit: 05 Sep 2010 @ 09:32 PM

EmailPermalink
Tags
Categories: django


 

Responses to this post » (None)

 
Post a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.


 Last 50 Posts
Change Theme...
  • Users » 348
  • Posts/Pages » 37
  • Comments » 16
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight

Quien Soy



    No Child Pages.

Consultoria



    No Child Pages.

galeria2



    No Child Pages.