IIRF是Ionic出品的ISAPI Rewriting Filter,专门为IIS服务的URL重写插件,完全开源,完全免费。
官方网站: http://iirf.codeplex.com/
使用IIRF在WIN2003+IIS6+.net2.0环境下使用一直正常,当安装.NET4.0版本后出现对于无扩展名的重写无效的问题,而带有扩展名的重写仍然有效。
经过查看日志,发现原URL /go/16315/44/
会变成 /go/16315/44/eurl.axd/2cbfd6147247e649b30eb7982f10a6bd
也就是无形中多了后面的 eurl.axd/2cbfd6147247e649b30eb7982f10a6bd 部分
为什么会出现这种现象呢?
经过同事积极Google后,在ASP.NET 4 Breaking Changes一文中找到了如下解决办法。
原文:http://hi.baidu.com/tuuboo/blog/item/0945d3fc2c4fbe43d6887dbb.html
在C语言中,三目运算经常用到(cond?a:b),非常的简洁,而在Python中不支持这种语法。
但是,可以用Python中and or来实现(这里是有陷阱的,下面会讲到)
我们来看下面几个表达式
>>> False or 1
1
>>> False or 0
0
>>> True or 0
True
>>> True and 1
1
>>>True and 0
0
>>> False and 1
False
由于测试需要在WIN平台上进行.264的MP4文件的拖动功能,而nginx windows官方版本不包含nginx_mod_h264_streaming-2.2.7模块,所以才有了本文。
安装库
gcc g++
zlib 库 (gzip 模块需要)
pcre 库 (rewrite 模块需要 )
openssl库 (ssl模块需要)
提示:国外下载库速度较慢,可以使用网易提供的开源站下载
http://mirrors.163.com/cygwin/
cd ~
wget http://nginx.org/download/nginx-0.8.54.tar.gz
wget http://nginx.org/download/nginx-1.0.0.tar.gz
cd ~
wget http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz
tar -zxvf nginx_mod_h264_streaming-2.2.7.tar.gz改动 ngx_http_h264_streaming_module.c,将以下内容全部移除或注释掉,否则会遇到 error: 'ngx_http_request_t' has no member named 'zero_in_uri'的错误提示
/* TODO: Win32 */ if (r->zero_in_uri) { return NGX_DECLINED; }
Python的异常处理能力是很强大的,可向用户准确反馈出错信息。在Python中,异常也是对象,可对它进行操作。所有异常都是基类Exception的成员。所有异常都从基类Exception继承,而且都在exceptions模块中定义。Python自动将所有异常名称放在内建命名空间中,所以程序不必导入exceptions模块即可使用异常。一旦引发而且没有捕捉SystemExit异常,程序执行就会终止。如果交互式会话遇到一个未被捕捉的SystemExit异常,会话就会终止。
原文:http://www.beardygeek.com/2010/03/adding-views-to-the-django-admin/
There are 2 ways to add urls to the admin: the quick and easy way, or the not so quick and easy way. In this case, as I was only adding a single url, I went for the quick and easy way. The other way involves extending the get_urls() method of AdminSite, adding to the existing admin url pattern. I did this:
(r'^admin/mypage/$', 'myapp.views.my_admin_view'),
(r'^admin/', include(admin.site.urls)),
Make sure you add your page before the main admin include.
When you write your view make sure you use the staff_member_required decorator.
from django.contrib.admin.views.decorators import staff_member_required
...
@staff_member_required
def my_admin_view(request):
# view code
When rendering your view, also make sure you pass RequestContext to the template:
return render_to_response('my_template.html',
context_instance=RequestContext(request))
So that your view looks like it belongs in the admin area, you need to extend the admin base site template:
{% extends 'admin/base_site.html' %}
You’ll also want to add in i18n support, and the admin media:
{% load i18n adminmedia %}
If you want to add in extra styles you can use {% block extrastyle %}, and you could put javascript in {% block extrahead %}.
If you have a form on your page that includes date fields, you might want to have the nice django javascript form widgets. First you need to add the widgets to your form:
from django.contrib.admin import widgets
class AdminForm(forms.Form):
start_date = forms.DateField(label="Start date",
widget=widgets.AdminDateWidget())
Next you need to add in the following to your extrahead block (replace admin-media with whatever you’ve set your admin media url to):
<script type="text/javascript" src="/admin/jsi18n/"></script>
<script type="text/javascript" src="/admin-media/js/core.js"></script>
{{ form.media }}
You also need to add the admin forms css in the extrastyles block:
{{ block.super }}
<link rel="stylesheet" type="text/css" href="/admin-media/css/forms.css" />If you want to have the breadcrumb trail at the top of the page, you need to create your own breadcrumb:
{% block breadcrumbs %}<div class="breadcrumbs"><a href="/admin/">
{% trans "Home" %}</a> > My View</div>{% endblock %}
When I add a link in, I like it to go in one of the right column boxes, so I usually create a new one and put it above the recent actions box. To do this, you need to override the admin index.html file.
Create a directory in your templates directory called admin. Then copy the index.html file from django/contrib/admin/templates to your new directory.
You’ll see a block called ‘sidebar’. Under the ‘content-related’ div, place the following:
<div class="module">
<h2>Admin tools</h2>
<ul class="actionlist">
<li class="changelink">
<a href="/admin/mypage/">My View</a>
</li>
</ul>
</div>