Metadata-Version: 2.1
Name: pynamodb-polymorph
Version: 0.3.1
Summary: Calculated/copied attributes to support advanced single-table design in DynamoDB
Home-page: https://github.com/ryansb/pynamodb-polymorph
License: MIT
Description: # PynamoDB Polymorph
        
        This package has utilities that are useful when using PynamoDB with a
        single-table (polymorphic) design and overloading Global Secondary Indexes.
        
        Take for example a Publisher class that needs to use a compound key of their
        type prefix and their name. If you rely on callers doing the copy in code
        there is possibility for them to update the name without also updating the
        GSI sort key that contains the name. The `CompoundTemplateAttribute` uses
        `string.Template` templating to fill unicode or numeric attributes into a
        string template to build keys automatically.
        
        ```python
        class Publisher(Base, discriminator="Publisher"):
            name = UnicodeAttribute()
            description = UnicodeAttribute(default="")
            gsi1_pk = CopiedDiscriminatorAttribute(source="cls")
        
            _slug = "PUBLISHER"
            gsi1_sk = JoinedUnicodeAttribute(attrs=["_slug", 'name'], sep='#')
        
            # Alternative way to specify gsi1_sk using a `string.Template`.
            # This is best for cases that aren't simply joining attrs with a character
            # gsi1_sk = CompoundTemplateAttribute(
            #     template="PUBLISHER#$name",
            #     attrs=["name"],
            # )
        ```
        
        The template above will take any value in `name` and fill it in to the
        template, so `name="Random Book Publishing House"` will become a
        `gsi1_sk="PUBLISHER#Random Book Publishing House"`.
Platform: UNKNOWN
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.8
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Provides-Extra: testing
