Skip to content

Instantly share code, notes, and snippets.

@bikeath1337
Created April 16, 2014 13:50
Show Gist options
  • Save bikeath1337/10878664 to your computer and use it in GitHub Desktop.
Save bikeath1337/10878664 to your computer and use it in GitHub Desktop.
Generate a nice_key with dborutils.key_service
from dborutils.mongo_client import NoodleMongoClient
from dborutils.key_service import NoodleKeyService
# Requires dborutils v0.2.2
collection_spec = "localhost:graduate:production"
namespace_client = NoodleMongoClient.create_from_mongo_spec(collection_spec)
# this returns the production collection from your client spec.
collection = namespace_client.collection()
# this needs to be set by the category, of course
prefix = 'gr'
nice_key = NoodleKeyService().generate_nice_key(namespace_collection=collection, prefix=prefix)
print nice_key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment