import loaders
loader = loaders.Lazy(
    '%s.models' % __name__,
    ('Upload',)
)

import extensions
from .functions import (
    delete,
    save,
    save_file,
    save_images,
)
from .models import Upload


def init(db, Storage, resizer=None):
    extensions.db = db
    extensions.resizer = resizer
    extensions.Storage = Storage
    loader.ready()

__all__ = (
    delete,
    init,
    save,
    save_file,
    save_images,
    Upload,
)

import loaders
loader = loaders.Lazy(
    '%s.models' % __name__,
    ('Upload',)
)

import extensions
from .functions import (
    delete,
    save,
    save_file,
    save_images,
)
from .models import Upload


def init(db, Storage, resizer=None):
    if 'upload' in db.metadata.tables:
        return  # Already registered the model.

    extensions.db = db
    extensions.resizer = resizer
    extensions.Storage = Storage
    loader.ready()

__all__ = (
    delete,
    init,
    save,
    save_file,
    save_images,
    Upload,
)

Make sure model isn't added several times.
Make sure model isn't added several times.

  import loaders
  loader = loaders.Lazy(
      '%s.models' % __name__,
      ('Upload',)
  )
  
  import extensions
  from .functions import (
      delete,
      save,
      save_file,
      save_images,
  )
  from .models import Upload
  
  
  def init(db, Storage, resizer=None):
+     if 'upload' in db.metadata.tables:
+         return  # Already registered the model.
+ 
      extensions.db = db
      extensions.resizer = resizer
      extensions.Storage = Storage
      loader.ready()
  
  __all__ = (
      delete,
      init,
      save,
      save_file,
      save_images,
      Upload,
  )
  
Make sure model isn't added several times.
## Code Before:
import loaders
loader = loaders.Lazy(
    '%s.models' % __name__,
    ('Upload',)
)

import extensions
from .functions import (
    delete,
    save,
    save_file,
    save_images,
)
from .models import Upload


def init(db, Storage, resizer=None):
    extensions.db = db
    extensions.resizer = resizer
    extensions.Storage = Storage
    loader.ready()

__all__ = (
    delete,
    init,
    save,
    save_file,
    save_images,
    Upload,
)

## Instruction:
Make sure model isn't added several times.
## Code After:
import loaders
loader = loaders.Lazy(
    '%s.models' % __name__,
    ('Upload',)
)

import extensions
from .functions import (
    delete,
    save,
    save_file,
    save_images,
)
from .models import Upload


def init(db, Storage, resizer=None):
    if 'upload' in db.metadata.tables:
        return  # Already registered the model.

    extensions.db = db
    extensions.resizer = resizer
    extensions.Storage = Storage
    loader.ready()

__all__ = (
    delete,
    init,
    save,
    save_file,
    save_images,
    Upload,
)
