[sqlalchemy] hexagonal architecture: isolate domain model from DB

2014-07-07 Thread avdd
Hi everyone Looking for some grey beard opinion. I recently came across Alistair Cockburn's Hexagonal architecture, aka. ports and adapters. http://blog.8thlight.com/uncle-bob/2012/08/13/the-clean-architecture.html The names are dubious but the basic idea is not new: separate the domain

[sqlalchemy] many-to-one relationship with intermediate table non equijoin

2013-08-14 Thread avdd
Hello all Tried for hours to figure out the various relationship() options with no luck. Consider: class Enrolment(base): __tablename__ = 'enrolment' person_id = Column(String, primary_key=True) group_id= Column(String, primary_key=True) enrol_date = Column(Date,

[sqlalchemy] Re: many-to-one relationship with intermediate table non equijoin

2013-08-14 Thread avdd
(Enrolment.next_date) == None)) ), uselist=False, viewonly=True) On Thursday, 15 August 2013 04:30:12 UTC+10, avdd wrote: Hello all Tried for hours to figure out the various relationship() options with no luck

[sqlalchemy] bug in dogpile advanced example?

2013-05-22 Thread avdd
two through twelve actually shows 25 .. 40 -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send

[sqlalchemy] event interface

2010-12-30 Thread avdd
Hi there Just wondering, before 0.7 is released and the API is baked, is it necessary to have all event names start with on_? It seems redundant and hackish. (Use a property?) Also, retval seems a prominent api symbol, it seems a shame to have such a strained abbreviation. returns ? a. --

[sqlalchemy] Re: event interface

2010-12-30 Thread avdd
python had a standard top- level namespace!) On Dec 31, 3:37 am, Michael Bayer mike...@zzzcomputing.com wrote: On Dec 30, 2010, at 8:35 AM, avdd wrote: Hi there Just wondering, before 0.7 is released and the API is baked, is it necessary to have all event names start with on_?  It seems

[sqlalchemy] Re: event interface

2010-12-30 Thread avdd
On Dec 31, 3:37 am, Michael Bayer mike...@zzzcomputing.com wrote: retval is not fantastic, though it is a known term used by pdb for instance.   returns as a boolean sounds like its suggesting the function may or may not return.   A non-abbrevated name would be has_return_value. I'd say

[sqlalchemy] Re: sqlalchemy and desktop apps

2010-07-24 Thread avdd
Hi Joel, Although my application is deployed on the web it was written with the goal of being redeployable as a desktop app, and to this end I have been able to abstract away the web details so that I can code my application very similarly to a desktop app. The relevance here is that all

[sqlalchemy] optimistic concurrency and relationships

2010-07-24 Thread avdd
I rely heavily on the version_id_col feature and I would like to be able to either explicitly increment the version, or have the version incremented when a relationship changes. The issue here is that a change in a relationship is a semantic change to the parent record and should conflict with

[sqlalchemy] Re: negative implications of using multiple declarative Base classes

2010-07-08 Thread avdd
I'm glad you brought this up. It seems to me that the the declarative instrumentation keys classes by their unqualified class name, precluding using the same class name for different declarative subclasses (ie, in different modules). On Jul 9, 12:01 pm, Randy Syring ra...@rcs-comp.com wrote:

[sqlalchemy] changing polymorphic class

2010-06-05 Thread avdd
Is there a reason for preventing updates to the polymorphic_on column? I tried removing that branch (mapper.py:1628) and the mapper tests all pass. (although there are problems with other tests that are unaffected by this change) a. -- You received this message because you are subscribed to

[sqlalchemy] More trouble with pickle and relations

2010-05-12 Thread avdd
setstate(state) File /home/avdd/work/careflight/src/intranet.ops/carenet/src/ sqlalchemy.6/lib/sqlalchemy/orm/collections.py, line 618, in __setstate__ self.attr = getattr(d['owner_state'].obj().__class__, d['key']).impl AttributeError: type object 'NoneType' has no attribute 'children2' -- You

[sqlalchemy] Re: need 0.6_beta2-compat declarative meta

2010-03-27 Thread avdd
In a metaclass's __init__, the attributes have already been placed on the class, so mutating the attributes dict has no effect. Try setting the id attribute directly: self.id = PrimaryKey(...) On Mar 27, 6:04 pm, Daniel Robbins drobb...@funtoo.org wrote: Hi All, In 0.6_beta2, the following

[sqlalchemy] Re: unable to understand this error

2010-02-16 Thread avdd
Hi anusha, The error is unrelated to your Login query because sqlalchemy compiles the mappers as late as possible. It might help if you put somewhere in your application code, after you have imported all your entities, the lines: from sqlalchemy import orm orm.compile_mappers() to catch

[sqlalchemy] Re: pickling errors

2010-02-14 Thread avdd
mike...@zzzcomputing.com wrote: On Feb 13, 2010, at 11:03 AM, avdd wrote: I'm getting some strange errors with unpickling.  I've tried all combinations of pickle/cPickle and protocol in (0,1,2) and still getting this apparent random error:  sqlalchemy.orm.collections:622 __setstate__

[sqlalchemy] pickling errors

2010-02-13 Thread avdd
I'm getting some strange errors with unpickling. I've tried all combinations of pickle/cPickle and protocol in (0,1,2) and still getting this apparent random error: sqlalchemy.orm.collections:622 __setstate__ self.attr = getattr(d['owner_state'].obj().__class__, d['key']).impl

[sqlalchemy] Confusion over postgresql drivers

2010-02-06 Thread avdd
Bruce Momjiam takes a swipe at the python postgresql drivers: http://archives.postgresql.org/pgsql-hackers/2010-02/msg00351.php Confined as the above discussion is to the ghetto of a mailing list, perhaps someone knowledgeable here can respond publicly? a. -- You received this message

[sqlalchemy] Re: session.add() vs session.merge() and delete child

2010-02-01 Thread avdd
So I get around this by essentially doing: # called on every request def refresh_model(context, obj): context.get_db().add(obj) def store_model(context, obj): db = object_session(obj) if db: db.expunge(obj) obj = db.merge(obj) db.flush() return obj Which seems to

[sqlalchemy] Re: session.add() vs session.merge() and delete child

2010-02-01 Thread avdd
On Feb 2, 2:52 am, Michael Bayer mike...@zzzcomputing.com wrote: the behavior you first illustrated, that of merge() and add() not acting the same regarding pending changes, was a behavior that was somewhat in the realm of a bug.   I mentioned the other day it was fixed in r6711.   Well no,

[sqlalchemy] session.add() vs session.merge() and delete child

2010-01-30 Thread avdd
I'm using session.add() to refresh my objects while working on them, because I don't want to merge them with the persistent state. But it appears deletes aren't carrying across to child relations: $ cat listdelete.py; python listdelete.py import sqlalchemy as sql from sqlalchemy import orm

[sqlalchemy] Re: session.add() vs session.merge() and delete child

2010-01-30 Thread avdd
On Jan 31, 4:33 am, Michael Bayer mike...@zzzcomputing.com wrote: this example is too compliated for me to understand without great effort, perhaps someone else has the time to follow it more closely - it appears to be creating and closing many new sessions and add()ing objects between them -

[sqlalchemy] orderinglist and delete-orphan cascade

2010-01-28 Thread avdd
(A).first().uc[0] with db.begin(): del db.query(A).first().oc[0] Traceback (most recent call last): File testordlist.py, line 40, in module del db.query(A).first().oc[0] File /home/avdd/tmp/src/sqlalchemy.5/lib/sqlalchemy/orm/ session.py, line 449, in __exit__ self.commit() File /home

[sqlalchemy] Re: orderinglist and delete-orphan cascade

2010-01-28 Thread avdd
On Jan 29, 3:52 am, Michael Bayer mike...@zzzcomputing.com wrote: you need to delete the object individually and flush before altering the collection. Thanks for the advice, but I can't do that because I'm working with objects (generically) in the detached state and committing later. I'll

[sqlalchemy] Re: Column property vs. Python (class) property for calculated columns

2010-01-18 Thread avdd
Here's my reworking of the example for time types: from datetime import datetime, timedelta, date from sqlalchemy import MetaData, Table, Column, DateTime, Date, Interval from sqlalchemy.orm import mapper, create_session metadata = MetaData('postgresql:///avdd') interval_table1 = Table

[sqlalchemy] Re: Column property vs. Python (class) property for calculated columns

2010-01-16 Thread avdd
The descriptor works by returning an SQL Expression when called on a class argument: Interval.length - SQL Expression Interval.contains(arg) - SQLExpression and operates normally on instances, ie, just runs the function. On Jan 15, 11:41 pm, bojanb boj...@gmail.com wrote: Thanks Mike. I

[sqlalchemy] array column as primary key

2010-01-13 Thread avdd
sqlalchemy.orm import sessionmaker from sqlalchemy import Column, Integer, create_engine from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.dialects.postgresql.base import ARRAY engine = create_engine('postgresql:///avdd') DB = sessionmaker(bind=engine) class A(declarative_base

[sqlalchemy] Re: array column as primary key

2010-01-13 Thread avdd
Thanks! Works great. On Jan 14, 2:27 am, Michael Bayer mike...@zzzcomputing.com wrote: avdd wrote: I want to map a table with a postgresql array as a primary key. PostgreSQL supports it, and everything works until the session wants to use the list returned from the query as an instance

[sqlalchemy] Re: lazy instrumented attributes and pickle

2009-12-17 Thread avdd
] sqlalchemy.orm.mapper: _get_state_attr_by_column return self._get_col_to_prop(column).getattr(state, column) sqlalchemy.orm.properties:99 getattr return state.get_impl(self.key).get(state, state.dict) AttributeError: 'NoneType' object has no attribute 'get' On Dec 17, 6:46 pm, avdd adr

[sqlalchemy] Re: base classes that have nothing to do with table inheritence

2009-12-17 Thread avdd
You could inject the attributes in a metaclass: def common_columns(): return dict(id = Column(Integer, primary_key=True), foo = Column(String)) Base = None class mymeta(DeclarativeMeta): def __init__(self, name, bases, attrs): if Base is not None: #

[sqlalchemy] Re: lazy instrumented attributes and pickle

2009-12-17 Thread avdd
/lib/python2.6/pickle.py, line 858, in load dispatch[key](self) File /usr/lib/python2.6/pickle.py, line 1217, in load_build setstate(state) File /home/avdd/tmp/src/sqlalchemy.5/lib/sqlalchemy/orm/ collections.py, line 612, in __setstate__ self.attr = getattr(d['owner_state'].obj

[sqlalchemy] Re: lazy instrumented attributes and pickle

2009-12-17 Thread avdd
On Dec 18, 12:58 pm, avdd adr...@gmail.com wrote: # testlazy.py No, I'm wrong. Investigating further... -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from

[sqlalchemy] Re: lazy instrumented attributes and pickle

2009-12-17 Thread avdd
Thanks, Mike. I was calling compile_mappers before importing the modules. Whoops! On Dec 18, 1:10 pm, avdd adr...@gmail.com wrote: On Dec 18, 12:58 pm, avdd adr...@gmail.com wrote: # testlazy.py No, I'm wrong.  Investigating further... -- You received this message because you

[sqlalchemy] lazy instrumented attributes and pickle

2009-12-16 Thread avdd
I use pickle to serialise unsaved objects in a user session. Normally this works fine, except that for development I use an auto-reloading server, and pickling some objects is hitting a case where some lazy attribute isn't fully compiled. ... File '/home/avdd/work/careflight/src/intranet.ops2

[sqlalchemy] merge, cascade and uselist=False

2009-12-13 Thread avdd
Hi I'm trying to merge objects across sessions and I'm seeing some odd behavour with a one-one child relation: import sqlalchemy as sql import sqlalchemy.orm as orm from sqlalchemy.ext.declarative import declarative_base engine = sql.create_engine('sqlite:///:memory:') metadata =

[sqlalchemy] Re: merge, cascade and uselist=False

2009-12-13 Thread avdd
On Dec 14, 12:35 pm, Michael Bayer mike...@zzzcomputing.com wrote: confirmed.  this is fixed in r6553 trunk/0.6 / r6554 0.5 branch. Thanks Mike, you're a legend! -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email

[sqlalchemy] Re: a renaming proposal

2007-07-27 Thread avdd
On Jul 27, 9:45 am, jason kirtland [EMAIL PROTECTED] wrote: This is the last opportunity for terminology changes for a while, so I offer this up for discussion. Does anyone else think orm.relation is wrong? Perhaps relationship if you must have a noun, or relates_to, etc, but relation could