Django RSS Feed Authentication

I am looking into adding RSS feeds to one of my Django apps and I would like to be able to have them be authenticated. I want to use the new syndication framework in Django 1.2. I've read the docs on how to do this and have the basic feeds setup. I am new to authenticating feeds, so I am not sure what the best approach to take is or what my options really are. Each user has a unique su

Django RSS源认证

我正在寻找添加RSS饲料给我的Django应用程序之一,我希望能够让他们进行身份验证。 我想在Django 1.2中使用新的联合框架。 我已阅读关于如何执行此操作的文档并进行基本的提要设置。 我是新来的认证饲料,所以我不知道最好的方法是什么或我的选择是什么。 每个用户都有一个唯一的子域,我希望URL结构看起来像这样: http://mysubdomain.mysite.com/myapp/rss/ : http://mysubdomain.mysite.com/myapp/rss/如果可能的话。

Python: a could be rounded to b in the general case

As a part of some unit testing code that I'm writing, I wrote the following function. The purpose of which is to determine if 'a' could be rounded to 'b', regardless of how accurate 'a' or 'b' are. def couldRoundTo(a,b): """Can you round a to some number of digits, such that it equals b?""" roundEnd = len(str(b)) if a == b: return True

Python:在一般情况下,a可以舍入到b

作为我编写的一些单元测试代码的一部分,我编写了以下函数。 其目的在于确定'a'是否可以舍入为'b',无论“a”或“b”的准确程度如何。 def couldRoundTo(a,b): """Can you round a to some number of digits, such that it equals b?""" roundEnd = len(str(b)) if a == b: return True for x in range(0,roundEnd): if round(a,x) == b: return True return Fals

How to access a data structure from a currently running Python process on Linux?

I have a long-running Python process that is generating more data than I planned for. My results are stored in a list that will be serialized (pickled) and written to disk when the program completes -- if it gets that far. But at this rate, it's more likely that the list will exhaust all 1+ GB free RAM and the process will crash, losing all my results in the process. I plan to modify my s

如何从Linux上当前运行的Python进程访问数据结构?

我有一个长期运行的Python进程,它产生的数据比我计划的要多。 我的结果存储在一个列表中,当程序完成后,它将被序列化(腌制)并写入磁盘 - 如果它达到那么远。 但是按照这个速度,这个列表很可能会耗尽所有1 GB以上的可用内存,并且这个过程会崩溃,在这个过程中失去了我所有的结果。 我计划修改我的脚本以定期将结果写入磁盘,但如果可能的话,我想保存当前正在运行的进程的结果。 有什么方法可以从正在运行的进程中获取

How do I track down a Heisenbug in some Python code?

Quick background: we have a large source base written in Python. It is a compiler for a domain specific language, and internally everything is represented as directed graphs. These digraphs are built up from sets, and so we use the builtin set type in Python. The problem is that we didn't originally realise that Python actively uses the lack of ordering guarantee in a set object to use a

如何在一些Python代码中追踪Heisenbug?

快速背景:我们有一个用Python编写的大型源代码库。 它是针对领域特定语言的编译器,内部一切都以有向图表示。 这些有向图由集合构成,因此我们在Python中使用内建集类型。 问题在于我们最初并没有意识到Python在set对象中主动使用缺乏排序保证来使用更快的非确定性实现。 所以当你迭代集合中的对象时(我们经常这样做),它们返回的顺序是弱随机的。 它在每次执行时都不会改变,但它确实经常改变。 根据我所看到的调试我

What is a right way for REST API response?

What is a best practice for REST API response structure and layout? Example of scrath: Success response : { "status": "success", "data": # some data here } Fail response : { "status": "fail", "data": { "code": # some error code, "message": # some error explaining message } } There is many ways to design you API response. It is c

什么是REST API响应的正确方法?

REST API响应结构和布局的最佳实践是什么? scrath的例子: 成功回应 : { "status": "success", "data": # some data here } 失败响应 : { "status": "fail", "data": { "code": # some error code, "message": # some error explaining message } } 有很多方法可以设计您的API响应。 这是以你的架构,技术和其他方面为条件的。 根据你的例子,我会以

What is a 'good practice' way to write a Python GTK+ application?

I'm currently writing a PyGTK application and I'd like some advice as to the best way to structure my application. Basically the application will read a specific file specification and present it in a GUI for editing. Currently I have a parser.py which handles all the low level file IO and parsing of the file. I'm displaying the contents of the file in a treeview, which means that

编写Python GTK +应用程序的“良好实践”方式是什么?

我目前正在编写一个PyGTK应用程序,我希望得到一些关于构建我的应用程序的最佳方式的建议。 基本上,应用程序将读取特定的文件规范并将其呈现在GUI中进行编辑。 目前我有一个parser.py,它处理所有低级文件IO并解析文件。 我在树形视图中显示文件的内容,这意味着我需要使用树存储作为我的数据类型。 我遇到的问题是我只想到两个解决这个问题的方法。 首先,我的解析器可以创建一个树库并将其传递给我的UI类。 这需要我

deleting object, keeping parent?

I have the following multi-table inheritance situation: from django.db import Models class Partner(models.Model): # this model contains common data for companies and persons code = models.CharField() name = models.CharField() class Person(Partner): # some person-specific data ssn = models.CharField() class Company(Partner): # some company-specific data tax_no = mod

删除对象,保持父母?

我有以下多表继承的情况: from django.db import Models class Partner(models.Model): # this model contains common data for companies and persons code = models.CharField() name = models.CharField() class Person(Partner): # some person-specific data ssn = models.CharField() class Company(Partner): # some company-specific data tax_no = models.CharField() 我如何将公司

What is a convenient way to store and retrieve boolean values in a CSV file

If I store a boolean value using the CSV module it gets converted to the strings 'True' or 'False' by the str() function. However when I load those values, a string of 'False' evaluates to being True because it's a non-empty string. I can work around it by 'manualy' checking the string at read time with an IF statement to see what the string is, but it's

什么是在CSV文件中存储和检索布尔值的便捷方式

如果我使用CSV模块存储一个布尔值,它将被str()函数转换为字符串'True'或'False'。 但是,当我加载这些值时,一串'False'的计算结果为True,因为它是非空字符串。 我可以通过在阅读时用'IF'语句检查字符串'manualy'来查看字符串是什么,但它有点不够优雅。 任何更好的想法,或者这只是编程世界中的那些东西之一? 我不认为Python的csv模块是可行的。 然而... 通过说您既可以

Python CJSON encoding custom objects

I am updating an old project that used an old version of cjson to speed up its json encoding. It also has a custom class called JSONString (which sets a string to its 'value' property) that is used for communicating with the database. It used to call cjson.encode((dict containing a JSONString), (custom encoding funct for JSONSTRING)) but the newer version of cjson has changed its param

Python CJSON编码自定义对象

我正在更新使用旧版cjson加速其json编码的旧项目。 它还有一个名为JSONString的自定义类(它将字符串设置为其'value'属性),用于与数据库进行通信。 它用来调用cjson.encode((包含JSONString的字典),(JSONSTRING的自定义编码函数)),但更新版本的cjson已将其参数更改为仅接受一个参数,并且不公开任何其他可能允许自定义编码过程。 在没有自定义编码器的情况下编码字典会引发EncodeError(对象不是JSON编码

JSON Output sent as Response to be wrapped in dictionary

I came across this section in the docs : RequestHandler.write(chunk) Writes the given chunk to the output buffer. To write the output to the network, use the flush() method below. If the given chunk is a dictionary, we write it as JSON and set the Content-Type of the response to be application/json. (if you want to send JSON as a different Content-Type, call set_header after calling writ

JSON输出作为响应发送以包装在字典中

我在文档中遇到了这个部分: RequestHandler.write(chunk) 将给定的块写入输出缓冲区。 要将输出写入网络,请使用下面的flush()方法。 如果给定的块是字典,我们将其编写为JSON并将响应的Content-Type设置为application / json。 (如果要将JSON作为其他Content-Type发送,请在调用write()后调用set_header)。 请注意,由于潜在的跨站点安全漏洞,列表不会转换为JSON。 所有的JSON输出都应该包含在字典中。 更