##// END OF EJS Templates
encryption: added new backend using cryptography + Fernet encryption....
encryption: added new backend using cryptography + Fernet encryption. - This would soon replace the old deprecated one based on pycrypto - We need a migration for the encryption data

File last commit:

r1753:79e2d284 default
r3522:3910c057 default
Show More
073_version_4_8_0.py
63 lines | 1.5 KiB | text/x-python | PythonLexer
hooks: added pushkey Mercurial hook....
r1753 import logging
from sqlalchemy import *
from rhodecode.model import meta
from rhodecode.lib.dbmigrate.versions import _reset_base, notify
log = logging.getLogger(__name__)
def get_by_key(cls, key):
return cls.query().filter(cls.ui_key == key).scalar()
def create_or_update_hook(cls, key, val, SESSION):
new_ui = get_by_key(cls, key) or cls()
new_ui.ui_section = 'hooks'
new_ui.ui_active = True
new_ui.ui_key = key
new_ui.ui_value = val
SESSION().add(new_ui)
def upgrade(migrate_engine):
"""
Upgrade operations go here.
Don't create your own engine; bind migrate_engine to your metadata
"""
_reset_base(migrate_engine)
from rhodecode.lib.dbmigrate.schema import db_4_7_0_0 as db
# issue fixups
fixups(db, meta.Session)
def downgrade(migrate_engine):
meta = MetaData()
meta.bind = migrate_engine
def fixups(models, _SESSION):
cleanup_if_present = (
'pushkey.key_push',
)
for hook in cleanup_if_present:
ui_cfg = models.RhodeCodeUi.query().filter(
models.RhodeCodeUi.ui_key == hook).scalar()
if ui_cfg is not None:
log.info('Removing RhodeCodeUI for hook "%s".', hook)
_SESSION().delete(ui_cfg)
to_add = [
('pushkey.key_push',
'python:vcsserver.hooks.key_push'),
]
for hook, value in to_add:
log.info('Adding RhodeCodeUI for hook "%s".', hook)
create_or_update_hook(models.RhodeCodeUi, hook, value, _SESSION)
_SESSION().commit()