fireblog package¶
Subpackages¶
- fireblog.scripts package
- fireblog.settings package
- fireblog.tests package
- Subpackages
- Submodules
- fireblog.tests.comments_test module
- fireblog.tests.conftest module
- fireblog.tests.functional_tests module
- fireblog.tests.login_test module
- fireblog.tests.models_test module
- fireblog.tests.renderer_globals_test module
- fireblog.tests.tags_test module
- fireblog.tests.tasks_test module
- fireblog.tests.views_test module
- Module contents
Submodules¶
fireblog.comments module¶
Functionality for adding, viewing and deleting comments.
-
fireblog.comments.add_comment_section_below_posts(event) → None[source]¶ This function should be passed an instance of
fireblog.events.RenderingPost. It adds a comment section onto the event parameter.
-
fireblog.comments.comment_add(request)[source]¶ Add a comment to a post.
We allow anyone to have access to this view. But we check whether a person is authenticated or not within this view. This is because we are allowing people to add comments anonymously ie not under an individual userid/username.
If a person is not authenticated, ie they are adding a comment anonymously, we run a Recaptcha test to try and avoid spam comments.
-
fireblog.comments.comment_delete(request)[source]¶ Delete a comment and redirect back to the post associated with the comment.
-
fireblog.comments.includeme(config)[source]¶ Add views for adding and deleting comments. Also, invalidate a cached post when we add or delete a comment on it.
-
fireblog.comments.render_comments_list_from_event(event) → list[source]¶ This function should be passed an instance of
fireblog.events.RenderingPost. It returns a list of comments associated with that post.
fireblog.dogpile_region module¶
fireblog.events module¶
Events that are fired off by views. Subscribers to these views get notified when the event is fired.
-
class
fireblog.events.CommentAdded(post, comment)[source]¶ Bases:
fireblog.events._CommentModifiedEvent that is fired when a comment has been added.
-
class
fireblog.events.CommentDeleted(post, comment)[source]¶ Bases:
fireblog.events._CommentModifiedEvent that is fired when a comment has been deleted.
-
class
fireblog.events.PostCreated(post)[source]¶ Bases:
fireblog.events._ModifyPostEvent that is fired when a post is created.
-
class
fireblog.events.PostDeleted(post)[source]¶ Bases:
fireblog.events._ModifyPostEvent that is fired when a post is being deleted.
fireblog.htmltruncate module¶
-
fireblog.htmltruncate.truncate(str, target_len, ellipsis='')[source]¶ Returns a copy of str truncated to target_len characters, preserving HTML markup (which does not count towards the length). Any tags that would be left open by truncation will be closed at the end of the returned string. Optionally append ellipsis if the string was truncated.
fireblog.login module¶
-
class
fireblog.login.Root(request)[source]¶ Bases:
objectResource tree to map groups to permissions. We allow admins to do anything, and commenters to be able to comment only.
-
fireblog.login.create_commenter_and_return_group(userid) → str[source]¶ This function assumes userid doesn’t exist in the db, and creates a new user with this userid, as a commenter.
Returns: group the user belongs to (g:commenter)
fireblog.models module¶
SQLAlchemy Database models.
-
class
fireblog.models.Comments(**kwargs)[source]¶ Bases:
sqlalchemy.ext.declarative.api.Base-
comment¶
-
created¶
-
id¶
-
post¶
-
post_id¶
-
uuid¶
-
-
class
fireblog.models.Post(**kwargs)[source]¶ Bases:
sqlalchemy.ext.declarative.api.Base-
created¶
-
html¶
-
id¶
-
markdown¶
-
name¶
-
uuid¶
-
-
class
fireblog.models.Settings(**kwargs)[source]¶ Bases:
sqlalchemy.ext.declarative.api.Base-
id¶
-
name¶
-
value¶
-
-
class
fireblog.models.Tags(**kwargs)[source]¶ Bases:
sqlalchemy.ext.declarative.api.Base-
id¶
-
tag¶
-
uuid¶
-
-
class
fireblog.models.Users(**kwargs)[source]¶ Bases:
sqlalchemy.ext.declarative.api.Base-
group¶
-
id¶
-
userid¶
-
username¶
-
uuid¶
-
-
fireblog.models.create_username(context) → str[source]¶ Create a username given an email address. If an email address is not supplied, an
Exceptionis raised. To generate a username, we first try to use the part before the ‘@’ in the email address. If this username already exists, we add random numbers to the end until we get a unique username.
fireblog.renderer_globals module¶
-
fireblog.renderer_globals.get_bower_url(request, path_to_resource: str) → str[source]¶ Generate a url which points to the supplied path_or_resource. The path_or_resource must exist in the /bower_components folder which is located ../../bower_components relative to the file this function is in.
fireblog.tags module¶
Views for managing tags, and viewing all posts with a particular tag.
Display a page listing all the tags that exist in the db, and how many posts have been tagged with each tag. The user can then rename one or more tags, and specify if any tags should be deleted.
Display a page similar to that of
fireblog.views.view_all_posts()but just showing the posts that have the supplied tag on them. The tag supplied isrequest.matchdict['tag_name'].
fireblog.theme module¶
Code that allows for changing the template files used at runtime. This provides support for themes, which are just folders containing template files.
-
class
fireblog.theme.TemplateResponseDict[source]¶ Bases:
dictInstances of this dict can be used as the return type of a view callable that is using the use_template decorator. The
use_template()decorator will notice that an instance of this type is being returned and render it to a response.This class is used in tandem with
template_response_adapter()
-
fireblog.theme.template_response_adapter(s: fireblog.theme.TemplateResponseDict)[source]¶ This function works in tandem with
TemplateResponseDict. This function assumes s is an instance ofTemplateResponseDict()and returns apyramid.response.Responsecontaining a string representation of s.
fireblog.utils module¶
-
fireblog.utils.format_datetime(datetime)[source]¶ Return a string representing the datetime object. eg ‘20 Jan 2014’
-
fireblog.utils.get_anonymous_userid() → str[source]¶ Returns the userid of the unique anonymous id. This userid is used whenever somneone wants to post a comment anonymously, as all comments must be associated with some author.
If the anonymous user doesn’t exist in the db, they are created on the fly.
fireblog.views module¶
Views for doing stuff with posts, generating RSS feeds and dealing with uuids.
-
class
fireblog.views.Add_Post(request)[source]¶ Bases:
objectViews that deal with adding a new post.
-
class
fireblog.views.Post_modifying_views(request)[source]¶ Bases:
objectViews that edit or delete posts.
-
fireblog.views.home(request)[source]¶ Call
view_post()and display the most recent post.
-
fireblog.views.includeme(config) → None[source]¶ Contains configuration to invalidate cached posts when they become invalid in various situations.
-
fireblog.views.invalidate_post(post_id)[source]¶ Invalidate post entry in the cache based on the supplied post_id.
-
fireblog.views.reload_fireblog(request)[source]¶ Reload (aka restart) the blog. This is done by telling uwsgi to reload.
-
fireblog.views.uuid(request)[source]¶ UUIDs are randomly generated strings associated with various objects. They are virtually guaranteed to be unique (by probability), and are used to provide permalinks to posts, posts with a certain tag, basically any kind of object.
This function redirects the user to a page that is the one associated to the supplied uuid (which is supplied as
request.matchdict['uuid']).
Module contents¶
-
fireblog.get_secret_settings(secrets_file: str, *, defaults: dict=None)[source]¶ Open secrets_file, which should be a filepath to an ini file, read in the DEFAULT section of the ini file, and return this as a dict.
Parameters: defaults – A dict of defaults to pass to configparser.ConfigParser.Returns: dict