Re: 0.9.7 and Elixir

2009-03-04 Thread Chris Curvey

On Feb 23, 2:27 pm, Philip Jenvey pjen...@underboss.org wrote:
 On Feb 23, 2009, at 10:58 AM, Chris Curvey wrote:

  I put the setup_all in load_environment (in environment.py), and that
  seemed to do no harm.  But I can't find a method called setup_config
  anywhere.

 websetup's setup_config changed to setup_app in 0.9.7.

 def setup_config(command, filename, section, vars)
 --
 def setup_app(command, conf, vars):

 Either one will work, regardless of version


Hmm.  I still haven't solved this, and its becoming more pressing.

If I run the script as delivered, I get the UnboundExecutionError.  So
I went into websetup.py, found the setup_app function, and added this
to it:

# create the tables if they are not there already
from sqlalchemy import create_engine
meta.metadata.bind = create_engine(conf['sqlalchemy.url'])
meta.metadata.create_all(checkfirst=True)

Now paster setup-app development.ini runs without errors (yay!) but
it does not create my one new table (boo!).  I even tried pulling out
the checkfirst parameter, but that seems to make no difference.

(Incidentally, I need to leave setup_all() in my __init__ file,
because my model directory is not in the Pylons project tree -- it's
somewhere else and imported by the pylons model/__init_)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: 0.9.7 and Elixir

2009-02-24 Thread Isaac

Shabti sounds interesting though I've not looked at it.

Here I've updated the pastebin thingy (and deleted the old one):
http://pylonshq.com/pasties/e0131b490dafc08b30633c506ca29931

--Isaac


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: 0.9.7 and Elixir

2009-02-24 Thread Graham Higgins



On Feb 24, 3:35 pm, Isaac nerk...@gmail.com wrote:
 Shabti sounds interesting though I've not looked at it.

 Here I've updated the pastebin thingy (and deleted the old 
 one):http://pylonshq.com/pasties/e0131b490dafc08b30633c506ca29931

Could you explain the reasoning behind your choice of kwargs to
sessionmaker? Are they related to using elixir or are they dictated by
the application?

++ # you may want different args to sessionmaker here:
++ Session = orm.scoped_session(orm.sessionmaker(autoflush=False,
expire_on_commit=False))

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: 0.9.7 and Elixir

2009-02-24 Thread Isaac



On Feb 24, 10:26 am, Graham Higgins gjhigg...@googlemail.com wrote:
 On Feb 24, 3:35 pm, Isaac nerk...@gmail.com wrote:

  Shabti sounds interesting though I've not looked at it.

  Here I've updated the pastebin thingy (and deleted the old 
  one):http://pylonshq.com/pasties/e0131b490dafc08b30633c506ca29931

 Could you explain the reasoning behind your choice of kwargs to
 sessionmaker? Are they related to using elixir or are they dictated by
 the application?

 ++ # you may want different args to sessionmaker here:
 ++ Session = orm.scoped_session(orm.sessionmaker(autoflush=False,
 expire_on_commit=False))

Hi,

Well, the best explanation I have is that these values are how I want
the Session to behave, which is why I put a comment saying you may
want to put something else there. Maybe some other values are more
sane for a typical or smaller app than the one I'm working on at the
moment (which is not small, and probably not typical). If there is
some agreement on that, I'll gladly make a new pastie with a
correction. :)

I suggest reading http://www.sqlalchemy.org/docs/05/reference/orm/
sessions.html#sqlalchemy.orm.sessionmaker for more explanation of
what those options do... try them out, and then decide what's right
for your situation/app.

HTH.
--isaac


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: 0.9.7 and Elixir

2009-02-24 Thread Graham Higgins



On Feb 24, 10:20 pm, Isaac nerk...@gmail.com wrote:
 Well, the best explanation I have is that these values are how I want
 the Session to behave, which is why I put a comment saying you may
 want to put something else there.

That's what I was following up :-)

 Maybe some other values are more sane for a typical or smaller app
 than the one I'm working on at the moment (which is not small, and
 probably not typical).

My reading of the SQLA docs suggests that the default values try to
strike a balance between improved operational reliability and
increased developer convenience. I just wondered if you thought that
your app had some particular characteristics that prompted your choice
--- not small, and probably not typical sounds like it fits the
bill.

 I suggest reading http://www.sqlalchemy.org/docs/05/reference/orm/
 sessions.html#sqlalchemy.orm.sessionmaker

Indeed. But Mike (understandably) barely hints at the operating
conditions that might prompt the adoption of a flush/commit strategy
other than the default. I write understandably because the
complexity introduced by the different characteristics of the various
relational persistences supported by SQLA probably places the matter
outside the scope of the SQLA docs.

 try them out, and then decide what's right for your situation/app.

That's a long and potentially expensive process. I'm just sculling
around trying to get a bead on things. I found this to be a useful 6-
or-so scrolling pages:

https://rhstack.108.redhat.com/articles/2007/02/09/design-issues-in-high-performance-transactional-applications-using-Java-and-Linux.html

(for others' reference) it's fairly well-packed: differences in how
databases handle concurrency, whether the database supports native
operating system threads (NPTL) or processes., Generally, synthetic
keys (sequences, auto-number) are preferred to business keys as
primary keys, It is also best if analytical schemas (such as those
used for monthly reporting systems) are kept separate from your
operational system schemas.

Partly answering my own (idle) question:

Another thing to watch out for with persistence solutions is when and
where they flush. Most persistence solutions gain a performance
advantage by scheduling updates and inserts to be sent to the database
lazily. By default, in Hibernate, this happens just before a query
is executed or just before a transaction actually commits at the
database level. The data must be flushed to the database just before a
query to assure accurate results.

Flushing is expensive. Most solutions do this generically without
noticing which entities are actually retrieved. You can potentially
gain a performance advantage by toggling the flush mode when you know
it's safe (e.g. not on large projects with lots of developers of
various skill levels); or by ordering your operations smartly to
execute non-dependent queries together before updates (although this
may be difficult to muster in a proper object-oriented/service-
oriented design). Playing with the flush mode and scheduling queries
is also how you can potentially run less sophisticated databases which
still use row locking in a lower isolation level (with a lot of
specific work) to achieve higher concurrency.

I still need to figure out how that plays back into my choice of
sessionmaker kwarg values but at least it's no longer an idle
question.

Thank you, Isaac.

Cheer,

Graham

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: 0.9.7 and Elixir

2009-02-24 Thread Isaac

Graham,

Thanks for the thoughtful reply. You indeed intuited something the app
is doing... its model is used to run a very lengthy conversion script
from an old FileMaker 6 database (the conversion script has more code
than the actual app because this database I inherited is structured
preposterously even considering what's needed to work around FMP 6's
copious limitations). It takes about 6 hours to run, but before I took
control of flushing it took around 23 hours. I may change those kwargs
when the app starts seeing normal use in a few weeks as the main
activity will change to mostly reading instead of mostly writing.

--i


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



0.9.7 and Elixir

2009-02-23 Thread Chris Curvey

I'm trying to set up a new project with 0.9.7 and Elixir.  I followed
the steps at http://cleverdevil.org/computing/68/ (I replaced the
contents of __init__ with the listed contents), and everything works
if I create my tables on my own.

But, how I can I tell Elixir to create the tables for me?  If I go
into paster shell and try to run create_all(), I get:

ProgrammingError: (ProgrammingError) (1146, Table
'mydatabase.mytablel' doesn't exist) 'DESCRIBE `mytable`' {}

If I try to run paster setup-app, I get:

sqlalchemy.exceptions.UnboundExecutionError: The MetaData is not bound
to an Engine or Connection.  Execution can not proceed without a
database to execute against.  Either execute with an explicit
connection or assign the MetaData's .bind to enable implicit
execution.

Did I miss something obvious?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: 0.9.7 and Elixir

2009-02-23 Thread Kumar McMillan

On Mon, Feb 23, 2009 at 10:57 AM, Chris Curvey ccur...@gmail.com wrote:

 I'm trying to set up a new project with 0.9.7 and Elixir.  I followed
 the steps at http://cleverdevil.org/computing/68/ (I replaced the
 contents of __init__ with the listed contents), and everything works
 if I create my tables on my own.

 But, how I can I tell Elixir to create the tables for me?  If I go
 into paster shell and try to run create_all(), I get:

 ProgrammingError: (ProgrammingError) (1146, Table
 'mydatabase.mytablel' doesn't exist) 'DESCRIBE `mytable`' {}

 If I try to run paster setup-app, I get:

 sqlalchemy.exceptions.UnboundExecutionError: The MetaData is not bound
 to an Engine or Connection.  Execution can not proceed without a
 database to execute against.  Either execute with an explicit
 connection or assign the MetaData's .bind to enable implicit
 execution.

It seems like you might be using reflection.  (Is that the default for
Elixir?  I forget.)  I would suggest not calling elixir.setup_all() at
the module level contrary to the article above.  Maybe the code is
trying to connect to the db before you get to the create_all() part?

I have Elixir working in 0.9.7.  Instead of setup_all() in __init__.py
I have it in load_environment() :

def load_environment(global_conf, app_conf):
# ...
# CONFIGURATION OPTIONS HERE (note: all config options will override
# any Pylons config options)

from sqlalchemy import create_engine
bind = create_engine(config['sqlalchemy.default.uri'])
elixir.metadata.bind = bind # probably a better way to do this
elixir.setup_all()

My websetup.py looks like:

def setup_config(command, filename, section, vars):
Place any commands to setup yourapp here
conf = appconfig('config:' + filename)
load_environment(conf.global_conf, conf.local_conf)




 Did I miss something obvious?
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: 0.9.7 and Elixir

2009-02-23 Thread Chris Curvey



On Feb 23, 1:20 pm, Kumar McMillan kumar.mcmil...@gmail.com wrote:
 On Mon, Feb 23, 2009 at 10:57 AM, Chris Curvey ccur...@gmail.com wrote:

  I'm trying to set up a new project with 0.9.7 and Elixir.  I followed
  the steps athttp://cleverdevil.org/computing/68/(I replaced the
  contents of __init__ with the listed contents), and everything works
  if I create my tables on my own.

  But, how I can I tell Elixir to create the tables for me?  If I go
  into paster shell and try to run create_all(), I get:

  ProgrammingError: (ProgrammingError) (1146, Table
  'mydatabase.mytablel' doesn't exist) 'DESCRIBE `mytable`' {}

  If I try to run paster setup-app, I get:

  sqlalchemy.exceptions.UnboundExecutionError: The MetaData is not bound
  to an Engine or Connection.  Execution can not proceed without a
  database to execute against.  Either execute with an explicit
  connection or assign the MetaData's .bind to enable implicit
  execution.

 It seems like you might be using reflection.  (Is that the default for
 Elixir?  I forget.)  I would suggest not calling elixir.setup_all() at
 the module level contrary to the article above.  Maybe the code is
 trying to connect to the db before you get to the create_all() part?

 I have Elixir working in 0.9.7.  Instead of setup_all() in __init__.py
 I have it in load_environment() :

 def load_environment(global_conf, app_conf):
     # ...
     # CONFIGURATION OPTIONS HERE (note: all config options will override
     # any Pylons config options)

     from sqlalchemy import create_engine
     bind = create_engine(config['sqlalchemy.default.uri'])
     elixir.metadata.bind = bind # probably a better way to do this
     elixir.setup_all()

 My websetup.py looks like:

 def setup_config(command, filename, section, vars):
     Place any commands to setup yourapp here
     conf = appconfig('config:' + filename)
     load_environment(conf.global_conf, conf.local_conf)


I put the setup_all in load_environment (in environment.py), and that
seemed to do no harm.  But I can't find a method called setup_config
anywhere.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: 0.9.7 and Elixir

2009-02-23 Thread Philip Jenvey


On Feb 23, 2009, at 10:58 AM, Chris Curvey wrote:

 I put the setup_all in load_environment (in environment.py), and that
 seemed to do no harm.  But I can't find a method called setup_config
 anywhere.

websetup's setup_config changed to setup_app in 0.9.7.

def setup_config(command, filename, section, vars)
--
def setup_app(command, conf, vars):

Either one will work, regardless of version

--
Philip Jenvey


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: 0.9.7 and Elixir

2009-02-23 Thread Isaac

Hi,

Here's a paste of how my app works with Pylons 0.9.7, Elixir 0.6.x,
SQLAlchemy 0.5.x.

http://pylonshq.com/pasties/c889fcaf392c198cd3482fae4db4dc90

Hope this helps...
--Isaac Csandl


On Feb 23, 12:58 pm, Chris Curvey ccur...@gmail.com wrote:
 On Feb 23, 1:20 pm, Kumar McMillan kumar.mcmil...@gmail.com wrote:



  On Mon, Feb 23, 2009 at 10:57 AM, Chris Curvey ccur...@gmail.com wrote:

   I'm trying to set up a new project with 0.9.7 and Elixir.  I followed
   the steps athttp://cleverdevil.org/computing/68/(Ireplaced the
   contents of __init__ with the listed contents), and everything works
   if I create my tables on my own.

   But, how I can I tell Elixir to create the tables for me?  If I go
   into paster shell and try to run create_all(), I get:

   ProgrammingError: (ProgrammingError) (1146, Table
   'mydatabase.mytablel' doesn't exist) 'DESCRIBE `mytable`' {}

   If I try to run paster setup-app, I get:

   sqlalchemy.exceptions.UnboundExecutionError: The MetaData is not bound
   to an Engine or Connection.  Execution can not proceed without a
   database to execute against.  Either execute with an explicit
   connection or assign the MetaData's .bind to enable implicit
   execution.

  It seems like you might be using reflection.  (Is that the default for
  Elixir?  I forget.)  I would suggest not calling elixir.setup_all() at
  the module level contrary to the article above.  Maybe the code is
  trying to connect to the db before you get to the create_all() part?

  I have Elixir working in 0.9.7.  Instead of setup_all() in __init__.py
  I have it in load_environment() :

  def load_environment(global_conf, app_conf):
      # ...
      # CONFIGURATION OPTIONS HERE (note: all config options will override
      # any Pylons config options)

      from sqlalchemy import create_engine
      bind = create_engine(config['sqlalchemy.default.uri'])
      elixir.metadata.bind = bind # probably a better way to do this
      elixir.setup_all()

  My websetup.py looks like:

  def setup_config(command, filename, section, vars):
      Place any commands to setup yourapp here
      conf = appconfig('config:' + filename)
      load_environment(conf.global_conf, conf.local_conf)

 I put the setup_all in load_environment (in environment.py), and that
 seemed to do no harm.  But I can't find a method called setup_config
 anywhere.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: 0.9.7 and Elixir

2009-02-23 Thread Isaac

Yee, nevermind that. This way worked with a very recent trunk but not
the release. I'll update that pastebin when all is working again.

On Feb 23, 1:41 pm, Isaac nerk...@gmail.com wrote:
 Hi,

 Here's a paste of how my app works with Pylons 0.9.7, Elixir 0.6.x,
 SQLAlchemy 0.5.x.

 http://pylonshq.com/pasties/c889fcaf392c198cd3482fae4db4dc90

 Hope this helps...
 --Isaac Csandl

 On Feb 23, 12:58 pm, Chris Curvey ccur...@gmail.com wrote:

  On Feb 23, 1:20 pm, Kumar McMillan kumar.mcmil...@gmail.com wrote:

   On Mon, Feb 23, 2009 at 10:57 AM, Chris Curvey ccur...@gmail.com wrote:

I'm trying to set up a new project with 0.9.7 and Elixir.  I followed
the steps athttp://cleverdevil.org/computing/68/(Ireplacedthe
contents of __init__ with the listed contents), and everything works
if I create my tables on my own.

But, how I can I tell Elixir to create the tables for me?  If I go
into paster shell and try to run create_all(), I get:

ProgrammingError: (ProgrammingError) (1146, Table
'mydatabase.mytablel' doesn't exist) 'DESCRIBE `mytable`' {}

If I try to run paster setup-app, I get:

sqlalchemy.exceptions.UnboundExecutionError: The MetaData is not bound
to an Engine or Connection.  Execution can not proceed without a
database to execute against.  Either execute with an explicit
connection or assign the MetaData's .bind to enable implicit
execution.

   It seems like you might be using reflection.  (Is that the default for
   Elixir?  I forget.)  I would suggest not calling elixir.setup_all() at
   the module level contrary to the article above.  Maybe the code is
   trying to connect to the db before you get to the create_all() part?

   I have Elixir working in 0.9.7.  Instead of setup_all() in __init__.py
   I have it in load_environment() :

   def load_environment(global_conf, app_conf):
       # ...
       # CONFIGURATION OPTIONS HERE (note: all config options will override
       # any Pylons config options)

       from sqlalchemy import create_engine
       bind = create_engine(config['sqlalchemy.default.uri'])
       elixir.metadata.bind = bind # probably a better way to do this
       elixir.setup_all()

   My websetup.py looks like:

   def setup_config(command, filename, section, vars):
       Place any commands to setup yourapp here
       conf = appconfig('config:' + filename)
       load_environment(conf.global_conf, conf.local_conf)

  I put the setup_all in load_environment (in environment.py), and that
  seemed to do no harm.  But I can't find a method called setup_config
  anywhere.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: 0.9.7 and Elixir

2009-02-23 Thread Graham Higgins

On Feb 23, 4:57 pm, Chris Curvey ccur...@gmail.com wrote:
 I'm trying to set up a new project with 0.9.7 and Elixir.

You might find some use in having a look at the project file
organisation and content of the basic Shabti template.

Shabti is a bitbucket fork of the old, mostly abandoned, tesla-pylons-
elixir Google project which at one time aimed to provide support for
using elixir with Pylons.

Shabti is a collection of Paste/Pylons templates basically adding
elixir to the standard project build and building on that to provide
the identity model originally implemented for tesla as well a whole
bunch of other things such as CouchDB, RDFAlchemy etc..

Shabti docs are on http://bel-epa.com/shabtidocs/index.html. It's not
quite ready for release yet, I need to make sure that the tests
execute properly but most of it works as expected. The kick-the-tyres
microsite is undergoing some last-minute changes (accreting a
Formbuild example).

HTH.

Graham
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---