django-shortuuidfield-0.1.3/0000755000076500000240000000000012572133462015701 5ustar benstaff00000000000000django-shortuuidfield-0.1.3/django_shortuuidfield.egg-info/0000755000076500000240000000000012572133462023747 5ustar benstaff00000000000000django-shortuuidfield-0.1.3/django_shortuuidfield.egg-info/dependency_links.txt0000644000076500000240000000000112572133462030015 0ustar benstaff00000000000000 django-shortuuidfield-0.1.3/django_shortuuidfield.egg-info/not-zip-safe0000644000076500000240000000000112572133462026175 0ustar benstaff00000000000000 django-shortuuidfield-0.1.3/django_shortuuidfield.egg-info/PKG-INFO0000644000076500000240000000105512572133462025045 0ustar benstaff00000000000000Metadata-Version: 1.1 Name: django-shortuuidfield Version: 0.1.3 Summary: Short UUIDField for Django. Good for use in urls & file names. (Base 57, 22 characters) Home-page: https://github.com/nebstrebor/django-shortuuidfield Author: Ben Roberts Author-email: roberts81@gmail.com License: UNKNOWN Description: UNKNOWN Platform: UNKNOWN Classifier: Framework :: Django Classifier: Intended Audience :: Developers Classifier: Intended Audience :: System Administrators Classifier: Operating System :: OS Independent Classifier: Topic :: Software Development django-shortuuidfield-0.1.3/django_shortuuidfield.egg-info/requires.txt0000644000076500000240000000002412572133462026343 0ustar benstaff00000000000000django shortuuid sixdjango-shortuuidfield-0.1.3/django_shortuuidfield.egg-info/SOURCES.txt0000644000076500000240000000060012572133462025627 0ustar benstaff00000000000000LICENSE MANIFEST.in README.rst setup.py django_shortuuidfield.egg-info/PKG-INFO django_shortuuidfield.egg-info/SOURCES.txt django_shortuuidfield.egg-info/dependency_links.txt django_shortuuidfield.egg-info/not-zip-safe django_shortuuidfield.egg-info/requires.txt django_shortuuidfield.egg-info/top_level.txt shortuuidfield/__init__.py shortuuidfield/fields.py shortuuidfield/models.pydjango-shortuuidfield-0.1.3/django_shortuuidfield.egg-info/top_level.txt0000644000076500000240000000001712572133462026477 0ustar benstaff00000000000000shortuuidfield django-shortuuidfield-0.1.3/LICENSE0000644000076500000240000000300412421233303016667 0ustar benstaff00000000000000Copyright (c) 2013 Benjamin Roberts, David Cramer and individual contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the django-uuidfield nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.django-shortuuidfield-0.1.3/MANIFEST.in0000644000076500000240000000010112421233303017413 0ustar benstaff00000000000000include setup.py README.rst LICENSE MANIFEST.in global-exclude *~django-shortuuidfield-0.1.3/PKG-INFO0000644000076500000240000000105512572133462016777 0ustar benstaff00000000000000Metadata-Version: 1.1 Name: django-shortuuidfield Version: 0.1.3 Summary: Short UUIDField for Django. Good for use in urls & file names. (Base 57, 22 characters) Home-page: https://github.com/nebstrebor/django-shortuuidfield Author: Ben Roberts Author-email: roberts81@gmail.com License: UNKNOWN Description: UNKNOWN Platform: UNKNOWN Classifier: Framework :: Django Classifier: Intended Audience :: Developers Classifier: Intended Audience :: System Administrators Classifier: Operating System :: OS Independent Classifier: Topic :: Software Development django-shortuuidfield-0.1.3/README.rst0000644000076500000240000000210312421233303017350 0ustar benstaff00000000000000django-shortuuidfield ---------------- Provides a ShortUUIDField for your Django models which uses the base-57 "Short UUID" package at https://github.com/stochastic-technologies/shortuuid/ . Originally, a fork from David Cramer's excellent django-uuidfield, but not much is left of that besides a bit of structure. Installation ============ Install it with pip (or easy_install):: pip install django-shortuuidfield Usage ===== First you'll need to attach a ShortUUIDField to your class. This acts as a char(22) to maintain compatibility with SQL versions:: from shortuuidfield import ShortUUIDField class MyModel(models.Model): uuid = ShortUUIDField() Enjoy! Notes ===== * ShortUUIDField is a subclass of django.db.models.CharField * You can pass usual Django CharField parameters on init, although some of them are added/overwritten: + max_length=22 (since we are using base-57 format which is fixed at 22 characters) + blank=True, editable=False (set auto=False to remove these fields enforcement) * Uses shortuuid.uuid() that generates uuid4 random values django-shortuuidfield-0.1.3/setup.cfg0000644000076500000240000000007312572133462017522 0ustar benstaff00000000000000[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 django-shortuuidfield-0.1.3/setup.py0000755000076500000240000000135612572133346017424 0ustar benstaff00000000000000from setuptools import setup, find_packages setup( name='django-shortuuidfield', version='0.1.3', author='Ben Roberts', author_email='roberts81@gmail.com', description='Short UUIDField for Django. Good for use in urls & file names. (Base 57, 22 characters)', url='https://github.com/nebstrebor/django-shortuuidfield', zip_safe=False, install_requires=[ 'django', 'shortuuid', 'six' ], packages=find_packages(), include_package_data=True, classifiers=[ "Framework :: Django", "Intended Audience :: Developers", "Intended Audience :: System Administrators", "Operating System :: OS Independent", "Topic :: Software Development" ], ) django-shortuuidfield-0.1.3/shortuuidfield/0000755000076500000240000000000012572133462020733 5ustar benstaff00000000000000django-shortuuidfield-0.1.3/shortuuidfield/__init__.py0000644000076500000240000000034312421233303023030 0ustar benstaff00000000000000from __future__ import absolute_import try: VERSION = __import__('pkg_resources') \ .get_distribution('django-shortuuidfield').version except Exception: VERSION = 'unknown' from .fields import ShortUUIDField django-shortuuidfield-0.1.3/shortuuidfield/fields.py0000644000076500000240000000336212572133346022560 0ustar benstaff00000000000000import shortuuid import six import sys from django.db.models import CharField class ShortUUIDField(CharField): """ A field which stores a Short UUID value in base57 format. This may also have the Boolean attribute 'auto' which will set the value on initial save to a new UUID value (calculated using shortuuid's default (uuid4)). Note that while all UUIDs are expected to be unique we enforce this with a DB constraint. """ def __init__(self, auto=True, *args, **kwargs): self.auto = auto # We store UUIDs in base57 format, which is fixed at 22 characters. kwargs['max_length'] = 22 if auto: # Do not let the user edit UUIDs if they are auto-assigned. kwargs['editable'] = False kwargs['blank'] = True # kwargs['unique'] = True # if you want to be paranoid, set unique=True in your instantiation of the field. super(ShortUUIDField, self).__init__(*args, **kwargs) def pre_save(self, model_instance, add): """ This is used to ensure that we auto-set values if required. See CharField.pre_save """ value = super(ShortUUIDField, self).pre_save(model_instance, add) if self.auto and not value: # Assign a new value for this attribute if required. value = six.text_type(shortuuid.uuid()) setattr(model_instance, self.attname, value) return value def formfield(self, **kwargs): if self.auto: return None return super(ShortUUIDField, self).formfield(**kwargs) try: from south.modelsinspector import add_introspection_rules add_introspection_rules([], [r"^shortuuidfield\.fields\.ShortUUIDField"]) except ImportError: pass django-shortuuidfield-0.1.3/shortuuidfield/models.py0000644000076500000240000000000012421233303022542 0ustar benstaff00000000000000