Skip to content

Commit

Permalink
various fixes; docstrings everywhere
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jan 13, 2015
1 parent 4422725 commit 57fa7be
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion comet/__main__.py
Expand Up @@ -64,17 +64,20 @@ def main():


def init(arguments):
u"""Run comet init."""
import comet.init
return comet.init.init()


def write_users(arguments):
u"""Write users to the DB."""
import comet.init
u = comet.utils.ask("Redis URL", "redis://")
u = comet.utils.ask("Redis URL", "redis://localhost:6379/0")
return comet.init.write_users(u)


def devserver(arguments):
u"""Run a development server."""
import comet.web
if comet.web.app:
port = int(arguments['--port'])
Expand Down
6 changes: 4 additions & 2 deletions comet/init.py
Expand Up @@ -26,18 +26,20 @@
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

from __future__ import print_function, unicode_literals
from comet.utils import PERMISSIONS, parse_redis
from comet.utils import PERMISSIONS
import redis

__all__ = ['init', 'write_users']


def init():
"""Initialize a site."""
print("ERROR: Not implemented.")
return 255


def write_users(dburl):
"""Write users to the DB."""
data = {
'username': 'admin',
'realname': 'Website Administrator',
Expand All @@ -48,7 +50,7 @@ def write_users(dburl):
for p in PERMISSIONS:
data[p] = '1'

db = redis.StrictRedis(**parse_redis(dburl))
db = redis.StrictRedis.from_url(dburl)
db.hmset('user:1', data)
db.hset('users', 'admin', '1')
if not db.exists('last_uid'):
Expand Down
3 changes: 2 additions & 1 deletion comet/web.py
Expand Up @@ -526,7 +526,7 @@ def index():
return render('comet_index.tmpl', context)


# TODO: delete (with redirects) as soon as `comet init` and real docs exist
# TODO: delete (with redirects) as soon as `comet init` exists
@app.route('/setup')
def setup():
"""TEMPORARY setup function."""
Expand Down Expand Up @@ -942,6 +942,7 @@ def acp_users_permissions():
action = 'edit'

def display_permission(user, permission):
"""Display a permission."""
checked = 'checked' if getattr(user, permission) else ''
if permission == 'wants_all_posts' and not user.can_edit_all_posts:
# If this happens, permissions are damaged.
Expand Down

0 comments on commit 57fa7be

Please sign in to comment.