Quixote学习笔记(4)

Quixote 立即下载

The _q_lookup() method

Now take a look at the ExtraDirectory class in extras.ptl. This class exhibits some more advanced publishing features. If you look back at the default _q_traverse() implementation (in directory.py), you will see that the _q_traverse does not give up if _q_translate() returns None, indicating that the path component has no designated corresponding attribute name. In this case, _q_traverse() tries calling self._q_lookup() to see if the object of interest can be found in a different way. Note that _q_lookup() takes the component as an argument and must return either (if there is more path to traverse) a Directory instance, or else (if the component is the last in the path) a callable or a string.

In this particular case, the ExtrasDirectory._q_lookup() call returns an instance of IntegerUI (a subclass of Directory). The interest here, unlike the ExtrasDirectory() instance itself, is created on-the-fly during the traversal, especially for this particular component. Try loading http://localhost:8080/extras/12/ to see how this behaves.

Note that the correct URL to get to the IntegerUI(12)._q_index() call ends with a '/'. This can sometimes be confusing to people who expect http://localhost:8080/extras/12 to yield the same page as http://localhost:8080/extras/12/. If given the path ['extras', '12'], the default _q_traverse() ends up calling the instance of IntegerUI. The Directory.__call__() (see directory.py) determines the result: if no form values were submitted and adding a slash would produce a page, the call returns the result of calling quixote.redirect(). The redirect() call here causes the server to issue a permanent redirect response to the path with the slash added. When this automatic redirect is used, a message is printed to the error log. If the conditions for a redirect are not met, the call falls back to raising a TraversalError. [Note, if you don't like this redirect behavior, override, replace, or delete Directory.__call__]

The _q_lookup() pattern is useful when you want to allow URL components that you either don't know or don't want to list in _q_exports ahead of time.



_q_lookup()是ExtraDirectory类的一个方法,代码如下:

     def  _q_lookup(self, component):
        
return  IntegerUI(component)

IntegerUI是一个类,在integers.ptl文件中。它接受一个可以转化为整数的路径组件做参数:

     def   __init__ (self, component):
        
try :
            self.n 
=  int(component)
        
except  ValueError, exc:
            
raise  TraversalError(str(exc))

计算阶乘的方法:

     def  factorial(self):
        
if  self.n  >   10000 :
            sys.stderr.write(
" warning: possible denial-of-service attack  "
                             
" (request for factorial(%d)) "   %  self.n)
        get_response().set_content_type(
" text/plain " )
        
return   " %d! = %d "   %  (self.n, fact(self.n))

上一个数字/下一个数字的方法:

     def  prev(self):
        
return  redirect( " ../%d/ "   %  (self.n - 1 ))

    
def  next(self):
        
return  redirect( " ../%d/ "   %  (self.n + 1 ))

_q_exports的内容:

_q_exports  =  [ "" ,  " factorial " ,  " prev " ,  " next " ]

_q_lookup()模板在你想允许事先并不知道或者不想在_q_exports中列出的路径组件时很有用。

注意点:访问时URL末尾的'/'不能少。
保姆级教程:在树莓派5B上用AI Kit跑YOLOv8,实测134fps的完整配置流程 本文提供了一份详细的树莓派5B搭配AI Kit部署YOLOv8的教程,从硬件组装到模型转换、优化和部署,最终实现134FPS的高帧率推理性能。通过Hailo-8L AI加速模块和HEF模型转换,这套方案为边缘AI计算提供了强大支持,适用于智能监控、无人机视觉导航等应用场景。 阅读详情

相关推荐

LED单元板驱动(HUB75接口)

开始之前先吐槽一下,搜这个的资料。要么都是Arduino,要么单片机的收费。小小的一个LED单元板,凭什么? 用Arduino是你速度快还是我ST,树莓派不好用?收费更离谱,这点东西还藏私?给你个中指凸。把原理都写出来看你怎么收费。 一、接口定义及原理 如图,有两个RGB通道,共占用6个IO。剩下的ABCDE为地址通道,LAT为行数据锁存通道,CLK为数据时钟,OE为低电平使能LED显示。图片这里没有E,证明它是16扫的,有E就会把B上面的地改为E。这样就是5位,2的5次方32扫。1.

a3748622的博客 3万+

学Quixote 一

 我不会读Quixote,金山词霸的发音也让我严重怀疑,音标读起来也拗口得很,我的烂英文水平啊。。。但手译一下会有好处的。原文地址:http://quixote.ca/overview/paper.html  White Paper: Quixote for Web Development白皮书:Quixote用于网站开发Introduction简介Quixot

宝记 3767

HIC测序数据生信分析——第三节,HIC数据挂载

(取决于是否运行①prune模块,若①运行,则③运行;#HIC预处理后的比对文件Unknown_BM942-001H0001_1_val_1.Unknown_BM942-001H0001_2_val_2.hicup.bam 和contig基因组序列文件genome.fa。#HIC预处理后的比对文件Unknown_BM942-001H0001_1_val_1.Unknown_BM942-001H0001_2_val_2.hicup.bam 和contig基因组序列文件genome.fa。#这个方法简单一点。

weixin_44616693的博客 3595

豆瓣动力核心——Quixote

**Quixot**e `['kwiksət; ki'həuti]` 发音:七号题~ n. 堂吉诃德(西班牙作家塞万提斯所著《堂吉诃德》中的主人公)

GeekLee的博客 2240

别再混淆了!一文彻底搞懂STM32的BootROM、BootLoader和启动模式(附启动流程图)

本文深入解析STM32的启动机制,详细讲解BootROM、BootLoader与启动模式的区别与联系,并提供实战指南。通过清晰的启动流程图和配置示例,帮助开发者彻底理解STM32启动流程,解决常见的启动问题,提升嵌入式开发效率。

weixin_33728268的博客 538

Android逆向进阶篇 Charles + Drony Vpn绕过代理检测方案 获取猫眼App数据

Android逆向进阶篇 Charles + Drony Vpn绕过代理检测方案 获取猫眼App数据

曾用名:极客柒 1852

学Quixote 零

很久没有写过程序了,很久没有写过python了。 不想生锈,不想拿本书老老实实的熟悉语法。开始一个项目,写些东西,过程中间自然会得到一些长进。ok,已经决定了,先去熟悉一下Quixote。

宝记 1046

音视频从入门到精通——指数哥伦布码原理

在计算机中,一般数字的编码都为二进制,但是由于以相等长度来记录不同数字,因此会出现很多的。

mirana的专栏 1381

Quixote笔记

Quixote的部署    在Quixote官方白皮书中已经详细描述了Quixote的工作模式。Quixote可以使用Python自代的http_server(主要用于开发调试)和与Apache(或lighttpd)配合使用。    Quixote与Apache配合使用方式如下: 使用CGI,文档中称为egular CGI。被认为效率最低的一种方式,因为每一个请求都会创建

在水一方 1744

以太网_RGMII接口与GMII接口的转化_03

RGMII接口转GMII接口!

weixin_42499230的博客 378

AMD机密计算虚拟机介绍

AMD机密计算虚拟机介绍

木简熙的博客 524

Quixote学习笔记(1)

Running the Quixote DemosQuixote comes with some demonstration applications in the demo directory. After quixote is installed (see INSTALL.txt for instructions), you can run the demos using the scri

celavi的专栏 1606

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

Quixote学习笔记(5)

The _q_resolve() methodNote that the ExtraDirectory class inherits from Resolving (in addition to Directory). The Resolving mixin modifies the _q_traverse() so that, when a component has an attri

celavi的专栏 1164

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

CentOS5.2下安装Lighttpd+Quixote+SCGi

研究了几天,文档实在是少的可怜,不过还是让我给搞出来了。呵呵 我在虚拟机上转的CentOS5.2,虚拟机是VMware Workstation 6.0.0 build-45731 装完CentOS没有yum update,觉得时间太久了,中途碰到一些需要安装的包,就只yum了下需要的包。 1、安装lighttpd tar xzvf lighttpd-1.4.22.t

教父的告白 2205

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

快速上手Quixote

快速上手QuixoteLuo Weifeng 2011-6-19关于Quixote的详细信息不了解的童鞋可以去官方网站看看:http://www.quixote.ca这里的快速实例使用的方案是:这里我们选择lighttpd。配置环境:注意:我使用的ubuntu标准版,如果使用window,配置是不同的,不在本文叙述中。1. 首先安装Quixote$sudo ap

765

quixote 学习笔记之一: apache2 及 scgi的配置

根据quixote 文档的推荐,使用SCGI方式和webserver 进行互联。 quixote: 2.7b2 mod-scgi: 1.14 Apache2 : 2.xx OS: ubuntu 10.04   一. 设置apache2 的虚拟主机(基于域名) 假设有以下两个域名:www.web.com : 处理quixote 应用 static.web.com : 处理...

shonelau 385

更改quixote默认的session名称

<br />quixote默认的session名称在config.py中定义:<br />SESSION_COOKIE_NAME = "QX_session"<br />把QX_session改成你希望的名字即可<br />在Debian 5.0.4系统中,该配置文件的路径是:<br />/usr/share/python-support/python-quixote/quixote/config.py

xiliuhu的专栏 467

Quixote学习笔记(3)

Understanding the root demoStart the root demo by running the command:simple_server.py --factory quixote.demo.create_publisherIn a browser, open http://localhost:8080 as before. Click around at

celavi的专栏 1227

豆瓣(douban.com)和Python、Quixote的文章合集

向阿北哥请教?    2005-12-31 21:54:09   来自: zh00yi (南京)  douban是用quixote和twisted做的,但好象都是python的web framework,为什么要用两个呢?能告诉我这两个分别用来做什么吗??我很想知道这方面的事,当然如果这属于商业秘密的话,可以不说的。。    2005-12-31 22:58:48 阿北 (北京)  quixote

celavi的专栏 7636

Quixote学习笔记(2)

Understanding the mini_demoStart the mini demo by running the command:simple_server.py --factory quixote.demo.mini_demo.create_publisherIn a browser, load http://localhost:8080. In your browser

celavi的专栏 1321

Quixote 1.2源码解读

要说quixote1.2真是老古董了,官网都已经不提供下载了(只维护1.3和2.x)。鉴于历史原因,公司暂时是不会做quixote升级的,而且就目前来看,完全没有问题。 下载源代码,主要看publish.py 有个publish方法: [code="python"] def publish(self, stdin, stdout, stderr, env): ""...

liaofeng_xiao的专栏 183

quixote app with nginx fastcgi redirect problem

[b]quixote app with nginx fastcgi redirect problem[/b] if you want to run quixote app with nginx fastcgi you need patch the publish.py file search with "request.get_environ('PATH_INFO', '')" t...

cunheise的专栏 179

win7 配置Python quixote Web Framework

这写这篇文章的时候,我找了很多python的web FrameWork框架,最后经过考虑,选择了 Quixote这框架,[下载地址]Quixote的优点: 简单,Quxiote的全部代码量为7000行左右,而且包含了大量的注释,如果去掉注释,则只有大约2500行代码。这也是我选择Quixote来学习Python的原因,因为你能容易通过阅读代码看到Quxiote做了什么。高效,这一方面得益于Pyt...

weixin_30652879的博客 117

配置Apache+mod_py+quixote

1.安装Python2.4.22.下载quixote包,运行setup.py install.    quixote将被拷贝到python的site-package目录下。3.Windows下直接安装,如果是Linux:上传Apache2源码到redhat.     命令行下:            ./configure            ./make             ./

480
上一篇: Quixote学习笔记(3)
下一篇: Quixote学习笔记(5)
爱尔兰熊猫
博客等级 码龄24年 13粉丝 15原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值