# Path: ringo/lib/helpers/misc.py
# def get_raw_value(element, name):
#     """Support getting the value for a dot separated attribute of
#     `element` provided by the `name` attribute. If the attribute name is
#     a dot separated attribute the function will first resolve the
#     attribute to the penultimate element and call the getattr method for
#     the ultimate element and the given value.
# 
#     E.g. If the function should get the attribute 'foo.bar.baz' the
#     function first gets the 'bar' element.  For this element the getattr
#     method will be called with the attribute 'baz'."""
# 
#     return _resolve_attribute(element, name)


import datetime
import json
import logging
import re
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy import (
    Column,
    Text,
    String,
    Integer,
    DateTime,
    ForeignKey,
    Table
)
from sqlalchemy.orm import (
    relationship,
    backref
)
from formbar.converters import to_date
from ringo.model import Base
from ringo.lib.helpers import get_raw_value
from ringo.lib.alchemy import get_columns_from_instance
        """Will update the updated attribute to the current datetime.
        The mapper and the target parameter will be the item which
        iherits this meta mixin.

        :request: Current request
        :item: Item handled in the update.

        """
        item.updated = datetime.datetime.utcnow()


class Blob(object):
    """Mixin to add a data fields to store form data as JSON in a single
    field. The mixin will overwrite the way how to get the form
    definiton and how to get values from the item."""
    data = Column(Text, default="{}")

    def __getattr__(self, name):
        """This function tries to get the given attribute of the item if
        it can not be found using the usual way to get attributes. In
        this case we will split the attribute name by "." and try to get
        the attribute along the "." separated attribute name."""
        data = getattr(self, 'data')
        if data:
            # In some cases it is needed to be able to trigger getting the
            # exapanded value without calling the get_value method. This can
            # be achieved by accessing the attribute with a special name.
            # Lets say you want to get the expanded value for `foo`. You get
            # this by asking for `foo__e_x_p_a_n_d`
            if name.endswith("__e_x_p_a_n_d"):

# Path: ringo/lib/helpers/misc.py
# def get_raw_value(element, name):
#     """Support getting the value for a dot separated attribute of
#     `element` provided by the `name` attribute. If the attribute name is
#     a dot separated attribute the function will first resolve the
#     attribute to the penultimate element and call the getattr method for
#     the ultimate element and the given value.
# 
#     E.g. If the function should get the attribute 'foo.bar.baz' the
#     function first gets the 'bar' element.  For this element the getattr
#     method will be called with the attribute 'baz'."""
# 
#     return _resolve_attribute(element, name)


# Path: ringo/model/mixins.py
import datetime
import json
import logging
import re
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy import (
    Column,
    Text,
    String,
    Integer,
    DateTime,
    ForeignKey,
    Table
)
from sqlalchemy.orm import (
    relationship,
    backref
)
from formbar.converters import to_date
from ringo.model import Base
from ringo.lib.helpers import get_raw_value
from ringo.lib.alchemy import get_columns_from_instance

        """Will update the updated attribute to the current datetime.
        The mapper and the target parameter will be the item which
        iherits this meta mixin.

        :request: Current request
        :item: Item handled in the update.

        """
        item.updated = datetime.datetime.utcnow()


class Blob(object):
    """Mixin to add a data fields to store form data as JSON in a single
    field. The mixin will overwrite the way how to get the form
    definiton and how to get values from the item."""
    data = Column(Text, default="{}")

    def __getattr__(self, name):
        """This function tries to get the given attribute of the item if
        it can not be found using the usual way to get attributes. In
        this case we will split the attribute name by "." and try to get
        the attribute along the "." separated attribute name."""
        data = getattr(self, 'data')
        if data:
            # In some cases it is needed to be able to trigger getting the
            # exapanded value without calling the get_value method. This can
            # be achieved by accessing the attribute with a special name.
            # Lets say you want to get the expanded value for `foo`. You get
            # this by asking for `foo__e_x_p_a_n_d`
            if name.endswith("__e_x_p_a_n_d"):

                return self.get_value(name.replace("__e_x_p_a_n_d", ""),