Re: Announcing SAContext 0.1.0

2007-06-23 Thread beachcoder

Great work ! Would it be fairly trivial to integrate this with
Elixir ?

On Jun 22, 7:37 pm, Mike Orr [EMAIL PROTECTED] wrote:
 I've released the first alpha version of SAContext, a class that
 bundles your SQLAlchemy engines, metadatas, and SessionContext into
 one convenient object like pylons.database.sesson_context only much
 better.

http://sluggo.scrapping.cc/python/sacontext/
http://cheeseshop.python.org/pypi/SAContext/0.1.0

 The API has been hammered out between me and Michael Bayer,
 SQLAlchemy's author, to provide flexibility for single-engine and
 multi-engine applications while sticking to his usage recommendations
 (which session_context does NOT do).

 I've added tickets to get this incorporated into Pylons:
http://pylonshq.com/project/pylonshq/ticket/261
 and SQLAlchemy:
http://www.sqlalchemy.org/trac/ticket/617
 This will take some testing and integration work. however.

 The SAContext class can be used in any SQLAlchemy application, and
 requires an explicit URI and engine args.  The test suite passes so
 this can be used as-is.
 PylonsSAContext is a subclass that optionally parses the specs from
 the Pylons configuration, with full support for various engine args
 and multiple databases.  The parsing method passes the test suite but
 the whole thing has not been used in a Pylons application yet.  I'll
 be testing it over the next week.  I'm releasing it now in case
 anybody wants to test it or make API suggestions.

 Basic usage from the docstring:

 # Connect to an engine.  The URI is mandatory but should be a
 # keyword arg.
 sac = SAContext(uri=sqlite://)# A SQLite memory database.

 # Or pass additional engine options.
 sac = SAContext(uri=mysql://..., engine_options={echo: True})

 # The metadata for this engine has automatically been created.
 users = Table(Users, sac.metadata, Column(...))

 # Or reflect the columns from an existing database table.
 users = Table(Users, sac.metadata, autoload=True)

 # ORM operations are managed by a hidden SessionContext that
 # automatically exposes a thread-specific session.
 sac.session.flush()

 # 'sac.query' is a shortcut for 'sac.session.query'.
 # (Use .list() instead of .all() in SQLALchemy  0.3.9.)
 records = sac.query(User).filter_by(...).all()

 # Mappers can use the SessionContext extension this way.
 # Note: the extension is optional, not required.
 mapper(User, users, extension=sac.ext)

 # You can connect to multiple databases.
 sac.add_engine(key=logs, uri=mysql://...)

 # Each engine has its own bound metadata.
 access_log = Table(Access, sac.get_metadata(logs), ...)

 # To access a non-default engine, do this.
 sac.get_engine(logs).echo = True

 PylonsSAContext works the same but its constructor and .add_engine are
 a bit more flexible:

 # Look up the URI in the config under 'sqlalchemy.default.dburi',
 # with engine options such as sqlalchemy.default.echo = true and
 # sqlalchemy.default.pool_recycle = 3600.  These are 
 automatically
 # converted to int/bool according to the SQLAlchemy manual.
 sac = PylonsSAContext()

 # Connect to a second database under 'squalchemy.database2.dburi'.
  sac.add_engine(database2)

  # Connect to a third database called logs but under the
 config key
  # 'sqlalchemy.engine3.dburi'.  If there's no 'echo_pool'
 option, default to
  # True.  Always set 'pool_recycle' to 3600 even if the config 
 says
  # otherwise.  Also pass in a pool class, which can't be
 specified in the
  # config file since it's not a scalar (string/int/bool).
  sac.add_engine(logs, config_key=engine3,
  engine_options={pool_recycle: 3600, poolclass:
 MyPoolClass},
  engine_defaults={echo_pool: True})

   # Connect to a fourth engine that's not in the config file.
   sac.add_engine(fourth, uri=mssql://..., engine_args={...})

   # Or don't use the config file at all.  (What are you smoking?)
   sac = PylonsSAContext(uri=sqlite:tmp/crack.sqlite)

 By default SAContext uses a bound metadata strategy which means
 every engine is paired with a bound MetaData.  The session is not
 aware of engines; it just executes queries and the metadatas find the
 engines.

 But if you pass a BoundSessionStrategy instance as SAContext(...,
 strategy=my_strategy), it will bind the engines to the session
 instead.  That's what pylons.database.session_context sorta does.
 Most applications don't need this but it's useful in a few cases.  I
 don't understand what those cases are but Michael mumbled 

Re: Toscawidget example partially renders tags as entities

2007-06-23 Thread Alberto Valverde


On Jun 22, 2007, at 7:25 PM, Brendan Arnold wrote:


 Hi there,

 I have followed the instructions on
 http://docs.pythonweb.org/display/pylonscookbook/Getting+Started 
 +With+ToscaWidgets+and+Pylons
 and although the example serves ok and outputs html, some of the
 fields later in the form (specifically the fields after the password
 confirm box to the submit button) are rendered with lt; and gt;
 entities and show up as html code on the page

 This was the case with the wsgi_app.py as well

 This isn't specific to my browser, I have tried with both ff and  
 opera.

 I have double checked the code and it seems to be exactly as in the  
 article.

 Some details,

 python 2.4.4
 Pylons-0.9.5
 paste 1.3
 myghty 1.1
 formencode 0.7.t
 toscawidgets 0.1a2dev
 twForms 0.1a2dev

 any ideas?

Try removing RuleDispatch and PyProtocols from your lib and reinstall  
them. This has happened before to some people and, though I'm not  
100% sure, I believe this issue is related to old versions of these  
libraries being around.

Alberto

BTW: Cross-posting to toscawidgets-discuss. Please follow up there.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Tesla - Adding event callbacks

2007-06-23 Thread Jonas

Thank you very much for creating the Elixir templates. I was following
your blog_ to get Elixir working on Pylons and so it's more
comfortable.

* Could you add the `Elixir event statements`_ in `lib/database.py`?

I am wishing the integration of Pylons/Tesla with Authkit. And with
Migrate (alpha?), Mako, Babel, and Toscawidgets too.

.. _blog: http://wordpress.com/tag/elixir/
.. _Elixir event statements: http://pylonshq.com/pasties/244


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Announcing SAContext 0.1.0

2007-06-23 Thread Mike Orr

Beachcoder: I don't know much about Exilir.  Is it just a table
definer?  If so, you'd create your engines/metadatas first in
SAContext and pass them to Exilir.  Then you could probably use
SAContext's session management with Exilir's tables.  But if Exilir
has its own session management, you'd probably want to use that
instead.  Anyway, it's worth somebody experimenting with.

On 6/23/07, voltron [EMAIL PROTECTED] wrote:
 Does that mean I can instantiate an SAContext object and I can use it
 everywhere? In websetup.py, my controllers e.t.c?

It was designed for the model, which is used by controllers.  It can
be used in websetup but you may have to take a couple extra steps
since the config is available differently in websetup.  If you do
CONFIG.push_process_config before using PylonsSAContext, it should
work normally.  (CONFIG is changing to pylons.config in Pylons 0.9.6
if I understand right, so the steps may change slightly.)  Otherwise
you'd have to call the config-parsing methods standalone to get the
options, and then pass the options literally to the constructor.  Or
maybe I could add a class method to do this in one step.

-- 
Mike Orr [EMAIL PROTECTED]

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Announcing SAContext 0.1.0

2007-06-23 Thread voltron

Does that mean I can instantiate an SAContext object and I can use it
everywhere? In websetup.py, my controllers e.t.c?

On Jun 23, 11:56 am, beachcoder [EMAIL PROTECTED] wrote:
 Great work ! Would it be fairly trivial to integrate this with
 Elixir ?

 On Jun 22, 7:37 pm, Mike Orr [EMAIL PROTECTED] wrote:

  I've released the first alpha version of SAContext, a class that
  bundles your SQLAlchemy engines, metadatas, and SessionContext into
  one convenient object like pylons.database.sesson_context only much
  better.

 http://sluggo.scrapping.cc/python/sacontext/
 http://cheeseshop.python.org/pypi/SAContext/0.1.0

  The API has been hammered out between me and Michael Bayer,
  SQLAlchemy's author, to provide flexibility for single-engine and
  multi-engine applications while sticking to his usage recommendations
  (which session_context does NOT do).

  I've added tickets to get this incorporated into Pylons:
 http://pylonshq.com/project/pylonshq/ticket/261
  and SQLAlchemy:
 http://www.sqlalchemy.org/trac/ticket/617
  This will take some testing and integration work. however.

  The SAContext class can be used in any SQLAlchemy application, and
  requires an explicit URI and engine args.  The test suite passes so
  this can be used as-is.
  PylonsSAContext is a subclass that optionally parses the specs from
  the Pylons configuration, with full support for various engine args
  and multiple databases.  The parsing method passes the test suite but
  the whole thing has not been used in a Pylons application yet.  I'll
  be testing it over the next week.  I'm releasing it now in case
  anybody wants to test it or make API suggestions.

  Basic usage from the docstring:

  # Connect to an engine.  The URI is mandatory but should be a
  # keyword arg.
  sac = SAContext(uri=sqlite://)# A SQLite memory database.

  # Or pass additional engine options.
  sac = SAContext(uri=mysql://..., engine_options={echo: 
  True})

  # The metadata for this engine has automatically been created.
  users = Table(Users, sac.metadata, Column(...))

  # Or reflect the columns from an existing database table.
  users = Table(Users, sac.metadata, autoload=True)

  # ORM operations are managed by a hidden SessionContext that
  # automatically exposes a thread-specific session.
  sac.session.flush()

  # 'sac.query' is a shortcut for 'sac.session.query'.
  # (Use .list() instead of .all() in SQLALchemy  0.3.9.)
  records = sac.query(User).filter_by(...).all()

  # Mappers can use the SessionContext extension this way.
  # Note: the extension is optional, not required.
  mapper(User, users, extension=sac.ext)

  # You can connect to multiple databases.
  sac.add_engine(key=logs, uri=mysql://...)

  # Each engine has its own bound metadata.
  access_log = Table(Access, sac.get_metadata(logs), ...)

  # To access a non-default engine, do this.
  sac.get_engine(logs).echo = True

  PylonsSAContext works the same but its constructor and .add_engine are
  a bit more flexible:

  # Look up the URI in the config under 
  'sqlalchemy.default.dburi',
  # with engine options such as sqlalchemy.default.echo = true 
  and
  # sqlalchemy.default.pool_recycle = 3600.  These are 
  automatically
  # converted to int/bool according to the SQLAlchemy manual.
  sac = PylonsSAContext()

  # Connect to a second database under 
  'squalchemy.database2.dburi'.
   sac.add_engine(database2)

   # Connect to a third database called logs but under the
  config key
   # 'sqlalchemy.engine3.dburi'.  If there's no 'echo_pool'
  option, default to
   # True.  Always set 'pool_recycle' to 3600 even if the config 
  says
   # otherwise.  Also pass in a pool class, which can't be
  specified in the
   # config file since it's not a scalar (string/int/bool).
   sac.add_engine(logs, config_key=engine3,
   engine_options={pool_recycle: 3600, poolclass:
  MyPoolClass},
   engine_defaults={echo_pool: True})

# Connect to a fourth engine that's not in the config file.
sac.add_engine(fourth, uri=mssql://..., engine_args={...})

# Or don't use the config file at all.  (What are you 
  smoking?)
sac = PylonsSAContext(uri=sqlite:tmp/crack.sqlite)

  By default SAContext uses a bound metadata strategy which means
  every engine is paired with a bound MetaData.  The session is not
  aware of engines; it just executes queries and the metadatas find the
  engines.

  But if you pass a BoundSessionStrategy instance as 

Re: Tesla - Adding event callbacks

2007-06-23 Thread beachcoder

Hi Jonas. I considered adding the callback code to Tesla, but I'm
holding off that as I think the Elixir core developers may be adding
something similar at some stage.

Migrate is definitely under consideration, depending on how stable/
usable it is, and Ben Bangert is working on a version of the Tesla
template with AuthKit and identity classes.

Otherwise, I'm holding off adding too much to Tesla, as the main aim
of the template is to make Pylons/Elixir/SA integration as easy as
possible, while leaving it open to use whatever form library, template
engine etc. you want (which is the Pylons philosophy). Mako in
particular will soon be the default template engine in any case.

 Thank you very much for creating the Elixir templates. I was following
 your blog_ to get Elixir working on Pylons and so it's more
 comfortable.

 * Could you add the `Elixir event statements`_ in `lib/database.py`?

 I am wishing the integration of Pylons/Tesla with Authkit. And with
 Migrate (alpha?), Mako, Babel, and Toscawidgets too.

 .. _blog:http://wordpress.com/tag/elixir/
 .. _Elixir event statements:http://pylonshq.com/pasties/244


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



reSTructured Text inside templates

2007-06-23 Thread kib2

Hi,

I've got several reSTructured Text articles written and I want to
publish them inside my Pylons templates (Mako ones).

Do you have any idea how should I do this (docutils generates
body's, so I must get rid of them ) ?

Thanks.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: reSTructured Text inside templates

2007-06-23 Thread Edin Salkovic

On 6/23/07, kib2 [EMAIL PROTECTED] wrote:

 Hi,

 I've got several reSTructured Text articles written and I want to
 publish them inside my Pylons templates (Mako ones).

 Do you have any idea how should I do this (docutils generates
 body's, so I must get rid of them ) ?

Have you checked out the QuickWiki tutorial (
http://docs.pythonweb.org/display/pylonsdocs/QuickWiki+Tutorial ).  If
I recall correctly there's a part where it describes using docutils to
proces reST syntax.

HTH,
Edin

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Getting ip of request?

2007-06-23 Thread griliard

I would like to take different actions based on the ip client
requesting a webpage.  Is it possible to get this information in
Pylons?  Looking at the request object, I can't see anything 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: reSTructured Text inside templates

2007-06-23 Thread kib2

Thanks for pointing me this one Edin, it works like a charm.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Getting ip of request?

2007-06-23 Thread Jose Galvez

try request.environ['REMOTE_ADDR']
Jose

griliard wrote:
 I would like to take different actions based on the ip client
 requesting a webpage.  Is it possible to get this information in
 Pylons?  Looking at the request object, I can't see anything 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---