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
| (cc(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 vario
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, primary
"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
On Dec 31, 3:37 am, Michael Bayer 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 "use_" rather than
nnoying
seeing type_ and such everywhere. (I wish python had a standard top-
level namespace!)
On Dec 31, 3:37 am, Michael Bayer 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
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.
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 oth
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 database
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 wrote:
> I have been, naive
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 the
in load
dispatch[key](self)
File "/usr/lib/python2.6/pickle.py", line 1217, in load_build
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(
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 wrote:
> Hi All,
>
> In 0.6_beta2, the following code is not prop
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 the
48 am, Michael Bayer 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 rand
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
AttributeErro
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 because
On Feb 2, 2:52 am, "Michael Bayer" 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, not in 0.5 (r6712).
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
This seems to be only a problem for FKs that are also PKs, i.e. if you
remove primary_key from C.p above, the example works as expected.
I'm just wondering, am I going to save myself a lot of pain if I stick
to surrogate, immutable primary keys?
--
You received this message because you are subsc
from sqlalchemy import orm
from sqlalchemy.ext.declarative import declarative_base
__metaclass__ = type
engine = sql.create_engine("postgresql:///avdd")
metadata = sql.MetaData(bind=engine)
db = orm.create_session(bind=engine, autocommit=False)
T = declarative_base(metadata=metadata)
clas
On Jan 31, 4:33 am, Michael Bayer 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 -
> an unusual series
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
from
On Jan 29, 3:52 am, "Michael Bayer" 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 find another way of
mai
l()
a = A(id=1)
a.oc = [OC(), OC()]
a.uc = [UC(i=1), UC(i=2)]
with db.begin():
db.add(a)
with db.begin():
del db.query(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
del db.query(A).
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
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 wrote:
> Thanks Mike. I must admit I don
Thanks! Works great.
On Jan 14, 2:27 am, "Michael Bayer" 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 quer
e_row!
"""
from 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 = sess
Thanks, Mike. I was calling compile_mappers before importing the
modules. Whoops!
On Dec 18, 1:10 pm, avdd wrote:
> On Dec 18, 12:58 pm, avdd wrote:
>
> > # testlazy.py
>
> No, I'm wrong. Investigating further...
--
You received this message because you are subscrib
On Dec 18, 12:58 pm, avdd 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 fro
db.merge(pickle.loads(a_pickle))
File "/usr/lib/python2.6/pickle.py", line 1374, in loads
return Unpickler(file).load()
File "/usr/lib/python2.6/pickle.py", line 858, in load
dispatch[key](self)
File "/usr/lib/python2.6/pickle.py", line 1217, in load_build
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:
# a
]
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,
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/int
On Dec 14, 12:35 pm, Michael Bayer 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 to sqlalch...@googlegro
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 = sql.MetaDat
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
"relati
38 matches
Mail list logo