本站首页    管理页面    写新日志    退出


«September 2025»
123456
78910111213
14151617181920
21222324252627
282930


公告
 本博客在此声明所有文章均为转摘,只做资料收集使用。

我的分类(专题)

日志更新

最新评论

留言板

链接

Blog信息
blog名称:
日志总数:1304
评论数量:2242
留言数量:5
访问次数:7620671
建立时间:2006年5月29日




[Django]Django教程
软件技术

lhwork 发表于 2007/2/1 11:54:54

一、Hello Django!

1、生成项目目录
django-admin.py startproject newtedst这样就在当前目录下创建了一个newtest 目录,里面有四个文件:
__init__.py  表示这是一个 Python 的package
manage.py  提供简单化的 django-admin.py 命令,特别是可以自动进行DJANGO_SETTINGS_MODULES和 PYTHONPATH 的处理
settings.py  Django的配置文件
uls.py          url映射处理文件,Django 的url映射是url对于某个模块方法的映射,目前不能自动


阅读全文(6079) | 回复(0) | 编辑 | 精华 | 删除
 


[Django]TextIndexingAbstractionLayer
软件技术

lhwork 发表于 2007/2/1 11:53:15

Introduction
Why do we need an abstraction layer for full-text indexing?
Developers often must implement search methods for their database, but unfortunately so far it has been easier to roll your own simple search than to deploy an existing project such as Lucene. Merquery provides an abstraction layer for popular text indexing engines and makes it easy for anyone to attach them to their database.

Using Merquery
You can enable Lucene indexing of a database table like so (assumi


阅读全文(1539) | 回复(0) | 编辑 | 精华 | 删除
 


[Django]Merquery Summer of Code Results
软件技术

lhwork 发表于 2007/2/1 11:52:44

http://blog.case.edu/bmb12/2006/08/merquery_summer_of_code_results

This morning I commited a working version of Merquery to the Django Subversion repository.

svn co http://code.djangoproject....

My code in particular lives in branches/search-api/django/contrib/search.

The Lucene adapter

阅读全文(2052) | 回复(0) | 编辑 | 精华 | 删除
 


[Django]More on Merquery
软件技术

lhwork 发表于 2007/2/1 11:50:24

http://blog.case.edu/bmb12/2006/03/more_on_merquery

A bunch of traffic has been directed to this blog due to the post about Merquery. Seems like there has been discussion going on in that posts's comments and also over at Jacob Kaplan-Moss' post.

As predicted, a lot of people are only seeing the "reinvention" aspect of Merquery. And admittedly, there is a lot that would need to be reinvented based on th

阅读全文(1778) | 回复(0) | 编辑 | 精华 | 删除
 


[Django]Custom SQL In Django
软件技术

lhwork 发表于 2007/2/1 11:49:14

For people wanting to write custom SQL queries for use in Django and are wondering how to make them "fit in" somehow with the rest of your code, a short tutorial follows. Requires a little bit of familiarity with Django to be useful, I suspect.

Also, if you are interested in learning more about some of the more advanced corners of Django, there are a few other people writing instructional pieces at the moment. In general, have a look at the Django aggregator for recent updates, but, in p

阅读全文(1898) | 回复(0) | 编辑 | 精华 | 删除
 


[Django]测试django的search api 大 | 中 | 小
软件技术

lhwork 发表于 2007/2/1 11:27:53

先定义一个model:
#newtest/wiki/person.py
from django.db import models

class Person(models.Model):
   first_name = models.CharField(maxlength=30)
   last_name = models.CharField(maxlength=30)
   biography = models.TextField()

   class Meta:
       db_table = 'person'
测试search api:
#newtest/wiki/test_searchapi.py
import os<

阅读全文(1881) | 回复(0) | 编辑 | 精华 | 删除
 


[Python]安装PyLucene
软件技术

lhwork 发表于 2007/2/1 11:20:49

1、安装gcc-3.4.4和gcj-3.4.4
tar -zxvf gcc-3.4.4.tar.gz
tar -zxvf gcc-java-3.4.4.tar.gz
mkdir build
cd build
../gcc-3.4.4/configure --enable-threads=posix --prefix=/usr/local/gcc-3.4.4 --enable-languages=c,c++,java
make bootstrap
sudo make install
export LD_LIBRARY_PATH=/usr/local/gcc-3.4.4/lib
export PATH=/usr/local/gcc-3.4.4/bin:${PATH}
2、安装PyLucene
tar

阅读全文(4778) | 回复(0) | 编辑 | 精华 | 删除
 


[Python]Python 学习笔记 (1)
软件技术

lhwork 发表于 2007/2/1 9:08:55

1、获取网页的方法 mport urllib

# GET
params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
f = urllib.urlopen("http://www.musi-cal.com/cgi-bin/query?%s" % params)
print f.read()

# POST
params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
f = urllib.urlopen("http://www.musi-cal.com/cgi-bin/query", params)
print f.read() 2、Cookie

阅读全文(2206) | 回复(0) | 编辑 | 精华 | 删除
 


[Python]一个批量转换文本文件编码的程序(Python)
软件技术

lhwork 发表于 2007/2/1 9:06:53

这个其实很简单的,用 decode() 和 和 encode 两个函数就可以搞定。 我需要的是 GB2312 跟 UTF-8 之间的转换,需要 Python 2.4 或者 Python 2.3 + CJKCodecs,要不然不支持 GB2312 的编码 用 GB2312 时,有时会出现错误,说某个字符不能识别,估计是超出了它的字符集的原因,由于 GBK 是它的扩展,索性就直接用 GBK 了。 此外就是目录遍历了,有一个非常好的工具 os.walk(),一次搞定。 完整的源代码如下:
阅读全文(3834) | 回复(0) | 编辑 | 精华 | 删除
 


[Python]用 Python 实现的线程池
软件技术

lhwork 发表于 2007/2/1 8:53:26

为了提高程序的效率,经常要用到多线程,尤其是IO等需要等待外部响应的部分。线程的创建、销毁和调度本身是有代价的,如果一个线程的任务相对简单,那这些时间和空间开销就不容忽视了,此时用线程池就是更好的选择,即创建一些线程然后反复利用它们,而不是在完成单个任务后就结束。 下面是用Python实现的通用的线程池代码: undefined
阅读全文(5175) | 回复(0) | 编辑 | 精华 | 删除
 





站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.109 second(s), page refreshed 144794488 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号