|
全局计数器用来作 Paging...
重构要做的事情
用 djangoform 代替原有的 form 将数据的读写从 view 函数中分离出来 改善 API 代码的用户认证、数据读写 pager 增加 query 参数 重新设计 model,将 post 和 page 合并为 Entry,用 type = 'post' 或 type = 'page' 区别 用 tag 代替 分类,清理 view.py 中的代码 去掉原先的sidebar 换掉现有的RTE 用 app.yaml 简化用户认证和静态文件处理 优化 url MetaWeblog API SpecificationIntroductionThe MetaWeblog API is an application programming interface that enables software to read and write weblog posts stored on a web server. The API has been implemented as an XML-RPC web service, so there are implementations supporting the API available in many popular programming languages. The MetaWeblog API is designed to extend the Blogger API, a blogging API that only can read and write the text of weblog posts. An additional API was needed to read and write elements such as a blog post's title, file enclosures, and categories. Most software that supports the Blogger API also supports the MetaWeblog API, and vice versa. Data TypesThe API employs the data types defined in XML-RPC, including the scalar types base64, boolean, int and string and the composite types array and struct. Error HandlingApplications that implement the API should use the fault-response scheme defined by XML-RPC. For example, trying to read, write, or edit a post without providing a valid username and password should generate a fault. Applications should display the error string to the user in a dialog box or server log, as appropriate. Use of RSS 2.0The API uses a struct to represent a blog post. Within the struct, the components of the post are represented by the elements of an item in the RSS syndication format, adopting the same name and usage as their RSS counterparts. Items in RSS can be extended by elements from namespaces, so the same is permitted in the MetaWeblog API. There's one exception: Categories are represented by a member named categories in the MetaWeblog API, unlike the RSS element which is named category. Common ParametersSeveral of the API's methods employ the same parameters: blogId, password, postId, publish, and username. The blogId, password, publish and username parameters are the same as the ones in the Blogger API. The blogId parameter is a string that contains a unique identifier for a blog. The username and password parameters are strings that contain authentication credentials to access that particular blog. The publish parameter is a boolean that's "true" if the blog update should be published immediately and "false" if it should be stored as a draft and not published. The postId parameter also follows the Blogger API. It is a string that contains an ID for the post, which is returned by the MetaWeblog API's newPost method and can be used as a parameter in the editPost and getPost methods. Reading and Writing Blog PostsThere are three methods that can be called in the API to read and write blog posts:
The content parameter of the newPost and editPost methods represents the content of a blog post and is a struct, not a string as it is in the corresponding methods of the Blogger API. The defined members of the struct are the elements of an item in RSS. The three basic members of the struct are the post's title, link and description. For blogging tools that don't support titles and links, the description member holds all of the post's content. Some elements of an RSS item have attributes such as the enclosure element, which has length, type and url attributes that describe a media file. To represent this in the MetaWeblog API, the value of the member should be a struct with names matching the attribute names.
The categories member holds a blog post's categories as an array of strings, with each string representing the name of a category. If a category is not defined on the blog, the category should be ignored rather than triggering an error. In calls to newPost or editPost, the struct may contain a member named flNotOnHomePage that contains the boolean "true" if the blog post must be excluded from the blog's home page and only appears on category pages. If this member is equal to "false" or not present, the post must be included on the home page. Some blogging tools may not support this functionality. The getPost method returns a struct that functions identically to the struct sent as a parameter to the newPost and editPost methods. A server implementing this API must ignore all elements that it doesn't support. Reading Multiple Blog PostsThe following method retrieves recent posts from a blog:
Each struct in the array returned by the method represents a recent blog post and holds the same members as a call to metaWeblog.getPost. The numberOfPosts parameter retrieves blog posts in reverse chronological order, so if numberOfPosts equals 1, the most recent post is retrieved; if it equals 2, the two most-recent posts are retrieved, and so on. If the numberOfPosts parameter is larger than the number of posts in the blog, all of the posts are retrieved. Reading CategoriesThe following method retrieves a list of categories defined by a blog:
The struct returned by the method contains one struct describing each category with three strings as members: description, htmlUrl and rssUrl. Uploading FilesThe following method transfers a file such as an image, audio or video to a blog:
The blogId, password and username parameters are the same ones employed in other methods of this API. The content struct must contain at least three members: bits, name and type. The name member is a string that holds the filename to assign the object on the blog server. If the name is the same as an existing file, implementers may replace the file. The type member is a string that identifies the MIME media type of the file, such as "audio/mpeg" for an MPEG audio file, "image/jpeg" for a JPEG graphic or "video/quicktime" for an Apple QuickTime video. The bits member is a base64-encoded binary value containing the content of the object. The struct may contain other elements, which should be ignored by blogging tools that do not support them. If the file transfer is successful, the newMediaObject method returns a struct that contains a member called url that represents the URL of the file. This URL must employ either the HTTP or FTP protocol. This method fails with an error if the file could not be transferred successfully. ExamplesHere's an example request using the API:
<methodCall> Here's an example response. <?xml version="1.0"?> Transmitting Elements with AttributesThe members of the struct used as a parameter to the editPost and newPost methods are borrowed from item elements in RSS. Most of the core elements of RSS lack attributes, so they can be represented simply in a struct. The enclosure and source elements have attributes and are structured as defined previously in this document. For other elements that have attributes, the following rules apply:
Because of these rules, no element can be passed through the MetaWeblog API that has an attribute named _value. CommentsThe Blogger API provides an appkey parameter that enables vendors to assign a developers key that can be used to track and potentially limit usage of the API. Though the MetaWeblog API doesn't employ this parameter in any of its methods, an appkey element can be added to the content struct parameter in the editPost, newPost and newMediaObject methods. CopyrightThis document is available under the terms of the Creative Commons Attribution/Share Alike license and has been authored by MetaWeblog API. RFC: MetaWeblog APIThu, Mar 14, 2002; by Dave Winer.
Document status future development
管理界面 页面评论 评论回复 存档 分类 / tag API Theme support 1.0: api auth potential bugs full link support category support simplify templates refactor sidebar code make stable designs of models 1.1: theme support fit for extension 1.2: optimization support uploading imgs to picasa 1.3: more integration with google services support importing from other blogs / blog engines favicon
zipserve /google/appengine/ext/admin (下水道) login: admin slug 简化url memcache property 等修饰符的使用可简化编码 URL and file path patterns use POSIX extended regular expression syntax, excluding collating elements and collation classes. Back-references to grouped matches (e.g. \1) are supported, as are these Perl extensions: \w \W \s \S \d \D (This is similar to Codesite search, plus back-reference support.)__getattr__ 与 __getattribute__的区别 http://docs.python.org/reference/datamodel.html#object.__getattribute__ Iterator objects also need to implement this method; they are required to return themselves. For more information on iterator objects, see Iterator Types. http://docs.python.org/reference/datamodel.html#object.__iter__ 活用 getattr 等内置函数 Property 的 multiline default choices参数 db.StringProperty(multiline=False,default='Micolog') dict 式的格式化字符串 '%(year)s/%(month)s/%(day)s/%(postname)s.html' Model.get_by_key_name categorie_keys=db.ListProperty(db.Key) auto_now: 最后修改时间 auto_now_add: 创建时间 entry_parent=db.IntegerProperty(default=0)#When level=0 show on main menu. menu_order=db.IntegerProperty(default=0) entrytype = ‘post' | 'page' EmailProperty @property def shortcontent(self,len=20): return self.content[:len] 待查:Sitemap_NotifySearch logging 模块 __metaclass__
http://docs.python.org/reference/datamodel.html#customizing-class-creation urllib.unquote(urllib.unquote(value)).decode('utf8') 很诡异 其实我的 Pager 写得蛮好的嘛 (不考虑效率的话) 改成这样好一点 def __init__(self, model=None,query=None, items_per_page=10): 基于类的dispatcher可能还是方便一点 username = args[pos+0] password = args[pos+1] args = args[0:pos]+args[pos+2:] @checkauth(pos=2) (in api_rpc.py) 这种写法未免太…… Uliweb提供了多种扩展的能力:
在Uliweb中,一个view函数是运行在某种环境中的,当需要调用view函数时,在调用前,我会向
函数的func_globals属性中注入一些对象,这些对象就可以直接在函数中使用了,你不再需要导入。
settings 是定义在所有有效的app settings.py文件中的配置项。注意,一个配置项的名称必须是 大写的。 views模块的初始化处理。在views模块中,如果你写了一个名为__begin__的函数,它将在执行 要处理的view函数之前被处理,它相当于一个入口。因此你可以在这里面做一些模块级别的处理, 比如检查用户的权限。因此建议你根据功能将view函数分到不同的模块中。 Key.from_path ?
google sitemap meta tag support
def post_struct(post):
link = full_url(post.get_absolute_url()) categories = post.tags.all() struct = { 'postid': post.id, 'title': post.title, 'link': link, 'permaLink': link, 'description': post.body, 'categories': [c.name for c in categories], 'userid': post.author.id, } if post.pub_date: struct['dateCreated'] = format_date(post.pub_date) return struct |