Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.2 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Libraries

    Elixir 0.7.1

    Download button

    No screenshots available
    Downloads: 631  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    Fair (2.6/5)
    18 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Gaetan de Menten | More programs
    MIT/X Consortium Lic... / FREE
    November 16th, 2009, 21:51 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    Elixir description

    Elixir is a declarative layer on top of SQLAlchemy.

    Elixir is a declarative layer on top of SQLAlchemy. The project is a fairly thin wrapper, which provides the ability to define model objects following the Active Record design pattern, and using a DSL syntax similar to that of the Ruby on Rails ActiveRecord system.

    Elixir does not intend to replace SQLAlchemy's core features, but instead focuses on providing a simpler syntax for defining model objects when you do not need the full expressiveness of SQLAlchemy's manual mapper definitions.

    Examples:

    The Elixir source distribution includes a sample web application that uses the TurboGears web application framework. The application builds upon the tutorial's Movie model to create a simple store for buying movies.

    The Video Store sample application also includes an example of how to use Elixir with the TurboGears "identity" framework for security and authorization. If you are planning to use Elixir with your TurboGears application, and need to support authorization using identity, you can use this model as a basis:

    from turbogears.database import metadata, session
    from elixir import Unicode, DateTime, String, Integer
    from elixir import Entity, has_field, using_options
    from elixir import has_many, belongs_to, has_and_belongs_to_many
    from sqlalchemy import ForeignKey
    from datetime import datetime

    class Visit(Entity):
    has_field('visit_key', String(40), primary_key=True)
    has_field('created', DateTime, nullable=False, default=datetime.now)
    has_field('expiry', DateTime)
    using_options(tablename='visit')

    @classmethod
    def lookup_visit(cls, visit_key):
    return Visit.get(visit_key)

    class VisitIdentity(Entity):
    has_field('visit_key', String(40), primary_key=True)
    has_field('user_id', Integer, ForeignKey('tg_user.user_id', name='user_id_fk', use_alter=True), index=True)
    using_options(tablename='visit_identity')

    class Group(Entity):
    has_field('group_id', Integer, primary_key=True)
    has_field('group_name', Unicode(16), unique=True)
    has_field('display_name', Unicode(255)),
    has_field('created', DateTime, default=datetime.now)
    has_and_belongs_to_many('users', of_kind='User', inverse='groups')
    has_and_belongs_to_many('permissions', of_kind='Permission', inverse='groups')
    using_options(tablename='tg_group')

    class User(Entity):
    has_field('user_id', Integer, primary_key=True)
    has_field('user_name', Unicode(16), unique=True)
    has_field('email_address', Unicode(255), unique=True)
    has_field('display_name', Unicode(255))
    has_field('password', Unicode(40))
    has_field('created', DateTime, default=datetime.now)
    has_and_belongs_to_many('groups', of_kind='Group', inverse='users')
    using_options(tablename='tg_user')

    @property
    def permissions(self):
    perms = set()
    for g in self.groups:
    perms = perms | set(g.permissions)
    return perms

    class Permission(Entity):
    has_field('permission_id', Integer, primary_key=True)
    has_field('permission_name', Unicode(16), unique=True)
    has_field('description', Unicode(255))
    has_and_belongs_to_many('groups', of_kind='Group', inverse='permissions')
    using_options(tablename='permission')

    More Elixir examples are coming soon, and we would appreciate any additional sample applications that you could provide to illustrate more complex mappings.


    Product's homepage

    Requirements:

    · SQLAlchemy
    · Python

      


    TAGS:

    declarative layer | SQLAlchemy layer | define model objects | Elixir | SQLAlchemy | declarative

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM