Add a few docstrings and update readme to-do list.

This commit is contained in:
voussoir 2017-11-16 16:46:39 -08:00
parent 8f000543ea
commit 74f4e74bdf
3 changed files with 18 additions and 0 deletions

View file

@ -50,6 +50,7 @@ If you are interested in helping, please raise an issue before making any pull r
- Make the FFmpeg path configurable. Some kind of global config? Or part of the database config file? It's not like every photodb needs a separate one. - Make the FFmpeg path configurable. Some kind of global config? Or part of the database config file? It's not like every photodb needs a separate one.
- Improve the appearance of album page. Too many section headers and the "Create album" interface should allow giving a title immediately. - Improve the appearance of album page. Too many section headers and the "Create album" interface should allow giving a title immediately.
- When users have '%' or '#', etc. in their username, it is difficult to access their /user/ URL. I would prefer to fix it without simply blacklisting those characters. - When users have '%' or '#', etc. in their username, it is difficult to access their /user/ URL. I would prefer to fix it without simply blacklisting those characters.
- Currently, the Jinja templates are having a tangling influence on the backend objects, because Jinja cannot import my other modules like bytestring, but it can access the methods of the objects I pass into the template. As a result, the objects have excess helper methods. Consider making them into Jinja filters instead. Which is also kind of ugly but will move that pollution out of the backend at least.
### To do list: User permissions ### To do list: User permissions
Here are some thoughts about the kinds of features that need to exist within the permission system. I don't know how I'll actually manage it just yet. Possibly a `permissions` table in the database with `user_id | permission` where `permission` is some reliably-formatted string. Here are some thoughts about the kinds of features that need to exist within the permission system. I don't know how I'll actually manage it just yet. Possibly a `permissions` table in the database with `user_id | permission` where `permission` is some reliably-formatted string.

View file

@ -12,6 +12,13 @@ def pascal_to_loudsnakes(text):
class ErrorTypeAdder(type): class ErrorTypeAdder(type):
''' '''
During definition, the Exception class will automatically receive a class
attribute called `error_type` which is just the class's name as a string
in the loudsnake casing style. NoSuchPhoto -> NO_SUCH_PHOTO.
This is used for serialization of the exception object and should
basically act as a status code when displaying the error to the user.
Thanks Unutbu Thanks Unutbu
http://stackoverflow.com/a/18126678 http://stackoverflow.com/a/18126678
''' '''
@ -20,6 +27,12 @@ class ErrorTypeAdder(type):
cls.error_type = pascal_to_loudsnakes(name) cls.error_type = pascal_to_loudsnakes(name)
class EtiquetteException(Exception, metaclass=ErrorTypeAdder): class EtiquetteException(Exception, metaclass=ErrorTypeAdder):
'''
Base type for all of the Etiquette exceptions.
Subtypes should have a class attribute `error_message`. The error message
may contain {format} strings which will be formatted using the
Exception's constructor arguments.
'''
error_message = '' error_message = ''
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.given_args = args self.given_args = args

View file

@ -325,6 +325,7 @@ class Album(ObjectBase, GroupableMixin):
photos = self.walk_photos() photos = self.walk_photos()
else: else:
photos = self.photos() photos = self.photos()
for photo in photos: for photo in photos:
photo.add_tag(tag, commit=False) photo.add_tag(tag, commit=False)
@ -499,6 +500,9 @@ class Bookmark(ObjectBase):
@decorators.required_feature('bookmark.edit') @decorators.required_feature('bookmark.edit')
@decorators.transaction @decorators.transaction
def edit(self, title=None, url=None, *, commit=True): def edit(self, title=None, url=None, *, commit=True):
'''
Change the title or URL. Leave None to keep current.
'''
if title is None and url is None: if title is None and url is None:
return return