?user-index函数-index函数

福建漳浦福发园艺场 位于福建省漳州市马口百里花卉走廊,这里有5000多亩的绿化种植面积,品种繁多,涉及乔木、灌木、棕榈科植物、盆景花卉。公司专业从事花卉苗木种植与销售,有华棕(老人葵)、银海枣(中东海枣)、加拿利海枣、大王椰子、苏铁、凤凰木、盆架子、鸡冠刺桐、小叶榕、大叶榕、重阳木、小叶榄仁、各种果树等,还有灌木类如黄金榕、遍地黄金、变叶木、扶搡、假连翘、非州茉莉、福建茶、黄蝉、肾蕨、龙船花、七里香等,还有各种大树桩景如榕树、香樟、红榕、重阳木、杜松等。
福建漳浦福发园艺场实力雄厚,重信用、守合同、保证产品质量,以多品种经营特色和薄利多销的原则,赢得了广大客户的信任。
热忱欢迎各界朋友,携手共创美好生活空间。
该公司暂无店铺,如有疑问请浏览求助下 django 的用户登陆成功后跳转至 index,需要显示用户名。这个全局变量如何传递? - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
已注册用户请 &
求助下 django 的用户登陆成功后跳转至 index,需要显示用户名。这个全局变量如何传递?
· 139 天前 · 676 次点击
views里面的代码index.html模版里面的代码HttpResponseRedirect(reverse('index'))只是跳转,但是没法传递全局变量或者变量。不知道我上面views里面的代码能否这样传递。有没有更好的办法?
7 回复 &| &直到
05:10:23 +08:00
& &139 天前
如果你只是想传递 request 或者 user 的话,直接在 settings 里添加 context processor 更简单一些,比如添加了 django.core.context_processors.request 就可以在模板里直接使用 request 对象了
& &139 天前
用户名你不是已经可以通过request.user.username获得了么,login之后request.user里就是当前用户对象了
& &139 天前
我习惯存在 session 里。。。
& &139 天前
up paloalto 我也习惯放session
& &139 天前
其实我的意思是login之后跳转到index里面的时候,index要知道username的值,是不是就是通过data['request'] = request来将request传递到模板里面来使得request.user.username能渲染成功。
& &139 天前
哦哦,以为你代码注释里提了两个问题,我理解不太到位。用1楼的方法就OK了 :)
& &138 天前
多谢。看了下手册的session 确实这样的解决办法好。总觉得吧request整个对象传递到模板里面太大了。再多问个问题。form验证里面有个auto_id属性,但是django总是form没有这个key,总报错。email=forms.EmailField(required=True,auto_id='%s',error_messages={'required':u'邮箱必须','invalid':u'请输入正确的邮箱'},widget=forms.TextInput(attrs={''class':'input-xlarge'}))(这个目的就是让form生成的input标签里面的id='email' 而不是默认的id='id_email'。下面是我自己的一个笨的解决办法:email=forms.EmailField(required=True,error_messages={'required':u'邮箱必须','invalid':u'请输入正确的邮箱'},widget=forms.TextInput(attrs={'id':'email','class':'input-xlarge'}))要是auto_id能用就好了。
& · & 827 人在线 & 最高记录 1065 & · &
创意工作者们的社区
Lovingly made by OLIVIDA
VERSION: 3.5.6.1 · 32ms · UTC 04:03 · PVG 12:03 · LAX 20:03 · JFK 23:03? Do have faith in what you're doing.From IEEE 1394 FireWire Wiki
Frequently Asked Questions
Also see the
Beware! This page is still way out of date.
page for locations of current driver sources.
cd /usr/src/linux (or the root of your kernel source tree)
cd drivers
move the existing drivers out of the way: mv ieee1394 ieee1394.orig
download the new ieee1394 directory from the
as a tarball or using svn with the checkout option
If you are using the drivers as modules: recompile and install the drivers, unload old modules, load new modules
If you are compiling the drivers into the kernel: recompile the kernel, install the kernel and update the boot loader, reboot
Remember, an understanding of kernel compilation and installation is a pre-requisite to the installation of ieee1394 and is beyond the scope of this document.
The Subversion linux-2.4 branch and perhaps other versions of ieee1394 are known to fail with the preempt kernel patch.
Do not try to compile modules directly from the ieee1394 you must compile from the top-level kernel source directory (e.g., /usr/src/linux).
If you get 1394 unrecognized symbol errors with crazy characters as part of the symbol names when you 'make modules_install' then try deleting all *.o in the ieee1394 directory, and run a 'make dep modules modules_install.'
Older versions of hotplug and Linux1394 drivers only recognized a SBP-2 storage device and loaded the corresponding sbp2 however, it did not register any devices with the SCSI subsystem.
New versions of Linux 1394 drivers (kernel 2.4.21+ or Subversion branches/linux-2.4) support hotplug for a number of device types including DV AV/C devices and Digital Camera.
In order to fully leverage this, a new hotplug agent script is available now in .
As of this writing (April 23, 2003), it is newer than what appears in any of the popular distributions.
Specifically, you need to replace /etc/hotplug/ieee1394.agent.
Next, make sure an /etc/hotplug/ieee1394 directory exists.
Then, you can create per-module scripts to make SCSI recognize partitions or start video applications.
A kernel 2.6 system does not need a hotplug/ieee1394/sbp2 script because there is direct however, a kernel 2.4 system should include /etc/hotplug/ieee1394/sbp2:
#!/bin/bash
if [ &${ACTION}& = &add& ]; then
. /etc/hotplug/ieee1394/rescan-scsi-bus.sh
. /etc/hotplug/ieee1394/rescan-scsi-bus.sh -r
Due to the completely unsafe implementation of the add/remove- single-device interface in the SCSI layer, automated calls of
are dangerous.
Badly timed runs of that script may cause the kernel to oops or freeze.
This happens especially if a rescan is run while the sbp2 host is removed.
This particular situation does not occur in "typical" desktop usage, but it is not so far off given the time a rescan may take with more and/or slow SBP-2 devices.
An alternative to all of the above is to
the Linux 2.4 SCSI subsystem to expose functions that allow sbp2 to communicate directly.
After applying the patch, you must uncomment "#define SBP2_USE_SCSI_ADDREM_HACK" in drivers/ieee1394/sbp2.c.
Finally, recompile and reload/reboot.
/etc/hotplug/ieee1394/dv1394 for DV cameras:
#!/bin/bash
if [ &${ACTION}& = &add& ]; then
/etc/hotplug/ieee1394/video1394 for Digital Camera:
#!/bin/bash
if [ &${ACTION}& = &add& ]; then
There is a preliminary
It is neither stable nor fully standards ()
compliant--but getting close!
Please test out with another Linux machine and submit bug reports and patches to the linux1394-devel mailing list.
Only recent versions of ieee1394 for Linux kernel 2.6 contain the sysfs files to support generic udev rules in order to create the /dev nodes for the protocol drivers.
This means you need a 2.6.12 or newer kernel or 2.6.11 with ieee1394 from the linux1394.org Subversion server (rev 1240+).
Create a file at /etc/udev/rules.d/10-ieee1394.rules, for example, with the following contents:
KERNEL==&raw1394&, NAME=&%k&, GROUP=&users&
KERNEL==&dv1394*&, NAME=&dv1394/%n&, GROUP=&users&
KERNEL==&video1394*&, NAME=&video1394/%n&, GROUP=&users&
Note that it is quite difficult to setup
under udev the same as devfs does because udev wants to create a single file per device, and symlinks will not work.
Answer added in October 2009
Many recent Linux distributions allow only the root user to access /dev/raw1394, either deliberately due to an incomplete understanding of FireWire security implications (Ubuntu), or because they didn't notice that some Ubuntu udev rules were merged into mainline udev.
In most desktop-oriented installations (if they still run the old ieee1394 driver stack rather than the ), it is most desirable to grant unprivileged users access to /dev/raw1394.
Otherwise, applications like coriander, dvgrab, ffado, or kino won't be able to recognize attached cameras or audio interfaces.
(Storage devices are unaffected because raw1394 is not used for them.)
Steps to fix this:
As root, make sure that the raw1394 driver is loaded into the kernel: modprobe raw1394
List ownership and permissions of the device file: ls -l /dev/raw1394
List the groups to which your normal account belongs to.
As normal user, run id
If /dev/raw1394 does not belong to a group of which you are member of, add an udev rule to permanently assign /dev/raw1394 to a suitable group.
As root, run echo 'KERNEL=="raw1394", GROUP="video"' & /etc/udev/rules.d/raw1394.rules Instead of video, you may have to use another group name depending on which groups were listed by id.
The new udev rule will be in effect after all subsequent reboots.
To activate this change for the current login session i.e. without reboot, simply reload raw1394 as root: modprobe -r raw1394; modprobe raw1394
Answer added in November 2009
The risks of user access to raw1394 are:
It allows direct control of FireWire-attached devices.
However, in order to do something really dangerous like overwriting device firmware or reading/ modifying data from a FireWire storage device, the user would need non-trivial purpose-made software.
It may allow read/ write access to memory of other PCs which are plugged into the FireWire bus together with the PC which runs raw1394.
Whether such access is possible and to which extent depends on the remote PC's operating system and hardware platform.
It may allow read/ write access to memory of your PC if you have more than one FireWire controller and plug them together to a single bus.
This depends on settings of the ohci1394 kernel driver and on the hardware platform of your PC.
In light of this, many people will consider it reasonably safe to allow unprivileged users access to /dev/raw1394 on a typical desktop PC.
Safety concerns with raw1394 and ohci1394 have been addressed by the replacement drivers firewire-core (which allows finer-grained access control due to separate device files per FireWire node) and firewire-ohci (which filters physical DMA).
driver/module is available at kernel configuration time, and many users are not sure whether to select it or not.
Essentially, you need it if an application you intend to use requires it.
You can check the documentation that comes with your application.
It is currently being used with , Coriander, and for DV export in Kino.
IMPORTANT:
video1394 is currently exclusive to the
driver and does not work with the
video1394 uses DMA (Direct Memory Access) technology available in hardware to make the data from isochronous channels on the 1394 bus available to applications.
The traditional methods available in the libraw1394 API require the CPU to copy the data from the kernel's memory space to the user space of the application.
Therefore, video1394's use of DMA is more efficient and requires less CPU usage.
It is simply newer and currently less well understood than the libraw1394 API.
Other benefits of video1394 include multi-buffering, frame synchronization, and the option to include 1394 headers, all performed in hardware.
The DMA capability is no longer exclusive to video1394.
and the new
isochronous API support DMA as well.
"Isochronous" is derived from the greek iso, which means uniform, and chronos, which means time.
This means data is transmitted at guaranteed regular intervals.
Most people think of this in terms of guaranteed bandwidth, but the timing is important too such that transmission will not be bursty.
Isochronous channels for data transmission is a primary feature of the IEEE 1394 bus.
The bus can handle up to 64 simultaneous channels.
Digital video is a good example example of isochronous data.
The Linux 1394 project implements isochronous send and receive through several interfaces: libraw1394, video1394, and dv1394.
First of all, video1394 only works with OHCI compliant adapters and the ohci1394 driver.
First, configure your kernel source to include the video1394 driver by either compiling it into the kernel or as a module.
Then, build your kernel or module.
Now, you need to make the device node:
mkdir /dev/video1394
mknod -m 666 /dev/video1394/0 c 171 16
The minor number indicates which adapater video1394 addresses.
In this case 16 refers to the first device.
So, if you have more than one card you can have multiple devices such as /dev/video1394/1 (minor=17), /dev/video1394/2 (minor=18), and so on.
Versions of video1394 older than kernel 2.4.19 use char-major 172 and minor 0.
In general, there are two classes of cameras:
DV and Digital Cameras.
In the 1394 world, a Digital Camera is a camera that sends uncompressed video and complies with the 1394 Trade Association's Digital Camera specification.
It is not a digital photo camera.
Note, however, there is at least one digital photo camera with a 1394 port, the professional Nikon D1.
However, it does not send DV nor Digital Camera uncompressed video.
Please see our
for some examples between these two classes of camera.
If you want to capture the video from your Digital Camera to disk, then you will need to write a program to do this yourself using libdc1394 and some video file format libraries.
A video4linux driver is planned, and you will then be able to use gstreamer or XawTv to capture video to the disk.
Coriander now captures still images to disk, ftp, or a Real streaming server.
Use Coriander.
It automatically determines if you have video1394 or Xvideo extensions for optimal performance.
Xvideo extensions are new with XFree86 4.0 and utilize the video YUV overlay features of your video card.
Not all video cards and XFree86 drivers support this feature.
Xv (short for Xvideo) provides a major performance advantage especially when used in conjunction with video1394.
There can be two reasons.
For one, you may not have instructed the camera to start isochronous transmission using libdc1394 or Coriander.
Secondly, due to an incomplete implementation of bus managment in the subsystem, your camera may refuse to start iso transmission.
A more complete implementation of bus management is currently being developed.
You can use dvgrab or Kino to capture DV into an AVI file.
Only Kino, Cinelerra, or the dvconnect utility from the libdv project can transmit DV back to the camera.
First of all, not all cameras support this functionality, in particular many PAL models.
Please check your documentation that came with your device to make sure it supports DV reception.
There are now three methods of exporting DV under Linux 1394: using video1394 (dvconnect, Kino, Cinelerra), using dv1394 (direct device file access, Kino, dv1394d), and using the new raw1394_iso API.
dv1394, in practice, is the most reliable at this time.
All of these devices comply with a standard called SBP-2 (Serial Bus Protocol-2).
They are accessed like SCSI devices in Linux since the sbp2 driver is a low-level SCSI provider.
for more information.
mount -t vfat /dev/sda1 /mnt
makes a DOS-format harddisk partition available in /mnt.
Replace /dev/sda1 by whatever device file is indicated by
fdisk -l /dev/sd?
cdrecord dev=0,0 -v -dummy image.iso
starts a simulation to burn a CD image to a CD-R. Remove the -dummy option when it appears to work okay.
Replace 0,0 by the numbers indicated by
cdrecord -scanbus
Did you run the rescan-scsi-bus.sh script mentioned on the
If that does not help, try
modprobe -r sbp2; modprobe sbp2
and watch /var/log/messages for output of the sbp2 driver and the SCSI drivers.
If there are error messages or no messages at all:
unload sbp2, all other 1394 drivers, and all SCSI drivers including ide-scsi and usb-storage, if applicable.
Then, try modprobe ohci1394 && modprobe sbp2.
If you run kernel 2.4.18 or older, please consider upgrading.
the linux1394-user mailing list.
Yes, provided the drive accepts multiple initiators, i.e. concurrent logins.
If in doubt, ask the manufacturer of the disk enclosure before purchase.
So far, only disks which are based on SBP-2 bridge chips from Oxford Semiconductor are known to support up to 2 or 4 concurrent logins, at least with Oxford Semi's reference firmware.
At the time of this writing, SBP-2 bridge chips from all other manufacturers (Initio, LSI, Prolific, Texas Instruments...) are known to not support multiple initiators.
Mailinglist discussions from , , .
Further requirements:
All hosts run Linux, the non-exclusive login option of
is used, and you take care for write locking and cache consistency, e.g. through a cluster filesystem.
that explains using Linux 1394 with the Oracle Cluster File System.
However, this is usually more difficult and troublesome than one expects or desires.
Therefore, we recommend to use SBP-2 from one host only and share the files over Samba or NFS.
Remember to unexport the disk and to "reload" the Samba or NFS service before you unmount and disconnect the drive.
Possible causes are bugs in Linux, firmware bugs of the drive, or defective hardware.
Make sure the drive and bridge do not overheat, which happens easily in non-ventilated enclosures.
Look for a firmware update:
Alas, firmware updaters typically run on Windows or Mac OS, and some SBP-2 bridges cannot be updated at all.
Use serialized sbp2 operation (see parameters on
driver page).
Note, serialized I/O is already the default mode since Linux 2.6.14, i.e. you don't need special load parameters.
(You can check that you have the correct parameters:
"cat /sys/module/sbp2/parameters/serialize_io" should show 1 or Y.)
By the way, you should use much more recent kernels than 2.6.14 anyway if you want reliable SBP-2.
Post-2.6.22 kernels need to use the workarounds=1 option to firewire_sbp2.
This claim is just wrong.
The flag 1 is no fix for this.
Under Linux 2.6, try the CFQ I/O scheduler:
echo cfq & /sys/block/sda/queue/scheduler
(Replace sda by the correct device name.)
Or make CFQ the default by appending the kernel parameter "elevator=cfq" at the boot prompt or in the boot loader configuration.
This hint is obsolete and misleading. It apparently papered over some sbp2 driver bugs on some setups in older kernels.
Use the command "eject /mnt/ipod" or "eject /dev/sdx".
(Check for the correct path with "mount".)
Yes, a PC or device running Linux can be turned into a FireWire disk (a so-called SBP-2 target) by means of the program .
This program currently only works together with the raw1394 driver (and ieee1394 and ohci1394 or pcilynx).
There is no SBP-2 target implementation available yet for the new alternative firewire drivers.
Personal tools
This page was last modified on 29 November 2009, at 19:27.Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
I'm trying to implement a horizontal multilevel dropdown navigation menu. Immediately below (vertically) the menu, I've got a YouTube video embedded via iframe. If I hover over one of the main level nav items in Firefox, the dropdown menu properly appears on top of the video.
Chrome and IE9, however, only a sliver of the dropdown is visible in the small region of space I have between the menu and the iframe.
The rest of it seems to be behind the iframe.
The problem seems to be related to the YouTube video, not the iframe. To test, I aimed the iframe at another web site rather than the video, and the dropdown menu worked fine, even in IE.
Question 1: WTF?
Question 2: Why, even if I explicity put a z-index:-999 !
on the iframe does this problem still occur?
Is there some internal CSS that the YouTube embed code includes that is somehow overriding things?
3,47251130
migrated from
This question came from our site for pro webmasters.
Try adding wmode, it seems to have two parameters.
&wmode=Opaque
&wmode=transparent
I can't find a technical reason why it works, or much more explanation but .
&iframe title="YouTube video player" width="480" height="390" src="/embed/lzQgAR_J1PI?wmode=transparent" frameborder="0" wmode="Opaque"&
//Fix z-index youtube video embedding
$(document).ready(function (){
$('iframe').each(function(){
var url = $(this).attr("src");
$(this).attr("src",url+"?wmode=transparent");
3,53752355
Joshc's answer was on the right track, but I found that it totally deletes the ?rel=0 querystring and replaces it with the ?wmode=transparent item - which has the effect of displaying the YouTube Suggested Videos list at the end of the playback, even though you originally didn't want this to happen.
I changed the code so that the src attribute of the embedded video is scanned first, to see if there is any question-mark in it already (because this denotes the presence of a pre-existing querystring, which might be something like ?rel=0 but could in theory be anything that YouTube choose to append in the future). If there's a querystring already there, we want to preserve it, not destroy it, because it represents a setting chosen by whoever pasted in this YouTube vid, and they presumably chose it for a reason!
So, if a? is found, the wmode=transparent will be appended using the format: &mode=transparent to just tag it on the end of the pre-existing querystring.
If no ?s are found, then the code will work in exactly the same way as it did originally (in toomanyairmiles's post), appending just ?wmode=transparent as a new querystring to the URL.
Now, regardless of what may or may not be on the end of the YouTube URL as a querystring already, it gets preserved, and the required wmode parameters get injected or added without damage to what was there before.
Here's the code to drop into your document.ready function:
$('iframe').each(function() {
var url = $(this).attr("src");
if ($(this).attr("src").indexOf("?") & 0) {
$(this).attr({
"src" : url + "&wmode=transparent",
"wmode" : "Opaque"
$(this).attr({
"src" : url + "?wmode=transparent",
"wmode" : "Opaque"
6,66092844
Just add one of these two to the src url:
&wmode=Opaque
&wmode=transparent
&iframe id="videoIframe" width="500" height="281" src="/embed/xxxxxx?rel=0&wmode=transparent" frameborder="0" allowfullscreen&&/iframe&
I have the same problem on youtube iframe embeds only in internet explorer though.
Z-index was being ignored totally, or the flash video was just appearing at highest index possible.
This was what I used, slight adapting the above jquery script.
My embed code, straight from youtube...
&iframe width="560" height="315" src="/embed/QldZiR9eQ_0?rel=0" frameborder="0" allowfullscreen&&/iframe&
The jQuery slighty adapted from the above answer...
$('iframe').each( function() {
var url = $(this).attr("src")
$(this).attr({
"src" : url.replace('?rel=0', '')+"?wmode=transparent",
"wmode" : "Opaque"
Basically if your don't select Show suggested videos when the video finishes in your embed settings, you have a ?rel=0 at the end of your "src" url. So I've added the replace bit incase ?rel=0 exists. Otherwise ?wmode=transparent won't work.
1,47653779
The answers abow didnt really work for me, i had a click event on the wrapper and ie 7,8,9,10 ignored the z-index, so my fix was giving the wrapper a background-color and it all of a sudden worked. Al though it was suppose to be transparent, so i defined the wrapper with the background-color white, and then opacity 0.01, and now it works. I also have the functions above, so it could be a combination.
I dont know why it works, im just happy it does.
We can simply add ?wmode=transparent to the end of YouTube URL. This will tell YouTube to include the video with the wmode set. So you new embed code will look like this:-
&iframe width="420" height="315" src="/embed/C4I84Gy-cPI?wmode=transparent" frameborder="0" allowfullscreen&
wmode=opaque or transparent at the beginning of my query string didnt solve anything. This issue for me only occurs on Chrome, and not across even all computers. Just one cpu.
It occurs in vimeo embeds as well, and possibly others.
My solution to to attach to the 'shown' and 'hidden' event of the bootstrap modals I am using, add a class which sets the iframe to 1x1 pixels, and remove the class when the modal closes. Seems like it works and is simple to implement.
BigJacko's Javascript code worked for me, but in my case I first had to add some JQuery "noconflict" code. Here's the revised version that worked on my site:
&script type="text/javascript"&
var $j = jQuery.noConflict();
jQuery(document).ready(function($j){
$j('iframe').each(function() {
var url = $j(this).attr("src");
if ($j(this).attr("src").indexOf("?") & 0) {
$j(this).attr({
"src" : url + "&wmode=transparent",
"wmode" : "Opaque"
$j(this).attr({
"src" : url + "?wmode=transparent",
"wmode" : "Opaque"
All you need on the iframe is:
...wmode="opaque"&&/iframe&
and in the URL:
/embed/123?wmode=transparent
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Stack Exchange
Post as a guest
required, but not shown
Post as a guest
required, but not shown
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled}

我要回帖

更多关于 index函数 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信