Monkinetic Weblog

XVI Edition, September 2025

More Navigation

Archives: Posts in 2013

← first ← previous page 11 of 39 next → last →


I've updated my post about a weird sqlalchemy error I don't understand: http://t.co/VCRMTJwH32 #help


When in doubt...

...put it in a transaction.

This nerd advice brought to you by flask and MySQL.

p.s. Anyone remember the msql/mysql wars of the mid 90s?


@kcunning wait what, where?


I may be teaching #python to my mother and daughter this year. Any thoughts on resources? LPTHW seems too nerdy. /cc @kcunning


@anildash Love it. http://t.co/3cq7lDab9N The paragraph about Indian people and social entertainment killed me. And made me think, too.


RT @fastly: @jacobian @littleidea Thanks for the recommendation! @whit537 We can definitely help. :)


@kcunning Wow, that's… wow.


RT @BergiesCoffee: I believe humans get a lot done, not because we're smart, but because we have thumbs so we can make coffee. ~Flash Rosen…


@pixel of course it is.


Anil Dash on Film, the Shushers and Cultural Norms

Oh, my, Anil. I do love your writing so much.

From the latest on "Shushers", people who demand that their movies are enjoyed by all according to their own monastic (great usage, Anil) habits.

>Indian folks get up, talk to each other, answer phone calls, see what snacks there are to eat, arrange marriages for their children, spontaneously break out in song and fall asleep. And that's during weddings! If Indian food had an equivalent to smores, people would be toasting that shit up on top of the pyre at funerals. So you better believe they're doing some texting during movies. And not just Bollywood flicks, but honest-to-gosh Mom-and-apple-pie American Hollywood films.

I can admit that I tend to be one of those monastic types, and I expect it's a bit of a generational thing. I don't like ditractions getting in the way of my enjoyment of a film, but it's not out of respect for the creators per se - I just like to immerse myself in a movie (even a bad one!). I don't think I've shushed anyone (for actual talking) more than twice in a theater ever, but it does bug me.

However, I love Anil's take on this and it's going to make me think more about how I consume films and the like in the future.


RT @jbarciauskas: Published a fork of a Chrome ext. to show caching status of Varnish pages: https://t.co/wX6ukA9rIp works with @fastly cc …


RT @scalzi: I'm not going to lie. I'm always disappointed when Japan launches a warship and it is NOT Space Cruiser Yamato: http://t.co/md4…


RT @dlutzy: Hush PagerDuty, don't say a word  Never mind that glitch you heard  It's just a blip, go back to bed   Nagios is not really red…


Crowning Moment of Heart Warming http://t.co/JG2TtPRhZ9


SqlAlchemy Relationship Error: 'property of that name exists on mapper'

The Setup

I'm writing a web app in python with Flask and SqlAlchemy with MySQL.

[the solution(#fixed)

The Code

Starting with the following (slightly snipped for brevity) python/SqlAlchemy code in `

/markbox/models.py`:

class UserBlog(ModelBase):
    __tablename__ = 'user_blog'

    id = sa.Column(sa.Integer, primary_key=True)
    uid = sa.Column(strcol)
    # blog title
    name = sa.Column(strcol)

    # returns a query => blog.sync_stats.all()
    sync_stats = relationship(
        'models.SyncStats', backref='blog',
        lazy='dynamic')

class SyncStats(ModelBase):
    """
    Store various statistics about sync operations
    """
    __tablename__ = 'system_syncstats'

    id = sa.Column(sa.Integer, primary_key=True)
    uid = sa.Column(strcol, sa.ForeignKey('user_blogsettings.uid'))

And this code in <project>/markbox/tools/test.py:

import sys
import os

sys.path.append(os.path.abspath('.'))
sys.path.append(os.path.abspath('markbox'))
print sys.path

from markbox.models import UserBlog, SyncStats

from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, DateTime
from sqlalchemy.orm import sessionmaker

SQLALCHEMY_DATABASE_URI = "mysql://markbox_user:markbox@localhost/markbox"

engine = create_engine(SQLALCHEMY_DATABASE_URI, echo='debug')
Session = sessionmaker(bind=engine)
session = Session()

if __name__ == '__main__':
    blog = UserBlog.query.limit(1)

The Error

When run from the command line in <project>:

% python markbox/tools/test.py

I get:

['/Users/sivy/Projects/personal/markbox/markbox/tools', ..., '/Users/sivy/Projects/personal/markbox', '/Users/sivy/Projects/personal/markbox/markbox']
Traceback (most recent call last):
  File "markbox/tools/test.py", line 25, in <module>
    blog = UserBlog.query.limit(1)
  File "/Users/sivy/.virtualenvs/markbox/lib/python2.7/site-packages/sqlalchemy/orm/scoping.py", line 131, in __get__
    mapper = class_mapper(owner)
  File "/Users/sivy/.virtualenvs/markbox/lib/python2.7/site-packages/sqlalchemy/orm/util.py", line 1112, in class_mapper
    mapper = _inspect_mapped_class(class_, configure=configure)
  File "/Users/sivy/.virtualenvs/markbox/lib/python2.7/site-packages/sqlalchemy/orm/util.py", line 1045, in _inspect_mapped_class
    mapperlib.configure_mappers()
  File "/Users/sivy/.virtualenvs/markbox/lib/python2.7/site-packages/sqlalchemy/orm/mapper.py", line 2122, in configure_mappers
    mapper._post_configure_properties()
  File "/Users/sivy/.virtualenvs/markbox/lib/python2.7/site-packages/sqlalchemy/orm/mapper.py", line 1244, in _post_configure_properties
    prop.init()
  File "/Users/sivy/.virtualenvs/markbox/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.py", line 231, in init
    self.do_init()
  File "/Users/sivy/.virtualenvs/markbox/lib/python2.7/site-packages/sqlalchemy/orm/properties.py", line 1031, in do_init
    self._generate_backref()
  File "/Users/sivy/.virtualenvs/markbox/lib/python2.7/site-packages/sqlalchemy/orm/properties.py", line 1220, in _generate_backref
    self, m))
sqlalchemy.exc.ArgumentError: Error creating backref 'blog' on relationship 'UserBlog.sync_stats': property of that name exists on mapper 'Mapper|SyncStats|system_syncstats'

What I've Done

I've already confirmed that:

  • the SyncStats model has no "blog" property (it used to have a method, decorated with @property).
  • I've deleted any existing *.pyc files to make sure that the interpreter is not picking up pre-compiled code.

The solution

So, the problem turned out to be that the models were being imported from two paths:

from models import UserBlog

and later:

from markbox.models import UserBlog

This caused the intilization code to be run twice, and the resulting error.


Z-index on a Glass browser should have a whole new meaning #css


RT @scalzi: That's just mean. http://t.co/LQXMnucq2B


Glory Box. So sublime #portishead


@agiletortoise Welder is a definite MUST HAVE.


RT @jasonbartz: The first step to writing a blog post is trying to remember how to use the blog software you wrote.

← first ← previous page 11 of 39 next → last →