##// END OF EJS Templates
translated resource map into full routes map, added validation for repos_group id
translated resource map into full routes map, added validation for repos_group id

File last commit:

r1271:aa7e45ad beta
r1348:dccba44e beta
Show More
meta.py
71 lines | 1.8 KiB | text/x-python | PythonLexer
renamed project to rhodecode
r547 """SQLAlchemy Metadata and Session object"""
from sqlalchemy.ext.declarative import declarative_base
Moved BaseModel into base class for declarative base. Added some handy methods into...
r1065 from sqlalchemy.orm import scoped_session, sessionmaker, class_mapper
from beaker import cache
renamed project to rhodecode
r547 from rhodecode.model import caching_query
Moved BaseModel into base class for declarative base. Added some handy methods into...
r1065
renamed project to rhodecode
r547
# Beaker CacheManager. A home base for cache configurations.
cache_manager = cache.CacheManager()
__all__ = ['Base', 'Session']
#
# SQLAlchemy session manager. Updated by model.init_model()
#
Session = scoped_session(
sessionmaker(
query_cls=caching_query.query_callable(cache_manager)
)
)
Fixed permissions for users groups, group can have create repo permission now....
r1271
Moved BaseModel into base class for declarative base. Added some handy methods into...
r1065 class BaseModel(object):
"""Base Model for all classess
source code cleanup: remove trailing white space, normalize file endings
r1203
Moved BaseModel into base class for declarative base. Added some handy methods into...
r1065 """
@classmethod
def _get_keys(cls):
"""return column names for this model """
return class_mapper(cls).c.keys()
def get_dict(self):
source code cleanup: remove trailing white space, normalize file endings
r1203 """return dict with keys and values corresponding
Moved BaseModel into base class for declarative base. Added some handy methods into...
r1065 to this model data """
d = {}
for k in self._get_keys():
d[k] = getattr(self, k)
return d
def get_appstruct(self):
source code cleanup: remove trailing white space, normalize file endings
r1203 """return list with keys and values tupples corresponding
Moved BaseModel into base class for declarative base. Added some handy methods into...
r1065 to this model data """
l = []
for k in self._get_keys():
l.append((k, getattr(self, k),))
return l
def populate_obj(self, populate_dict):
"""populate model with data from given populate_dict"""
for k in self._get_keys():
if k in populate_dict:
setattr(self, k, populate_dict[k])
@classmethod
def query(cls):
return Session.query(cls)
@classmethod
def get(cls, id_):
return Session.query(cls).get(id_)
renamed project to rhodecode
r547 # The declarative Base
Moved BaseModel into base class for declarative base. Added some handy methods into...
r1065 Base = declarative_base(cls=BaseModel)
renamed project to rhodecode
r547
#to use cache use this in query
#.options(FromCache("sqlalchemy_cache_type", "cachekey"))