Re: Pylons 0.9.5 + SAContext and nosetests gives additional warnings

2007-09-26 Thread Jim Musil

This is probably too late, but I had the same problem.

The problem is that tests are collected and tests/__init__.py runs
before any configuration is loaded and therefore cannot be referenced.
This makes it tough to test your db if you have connection variables
set in your test.ini files. Or sqlalchemy, which is looking for
configuration settings there.

You can make it work by subclassing the TestController class as talked
about here:

http://docs.pythonweb.org/pages/viewpage.action?pageId=9011209

Just make sure that any module or variable that needs a configuration
setting is in the context of the TestController.


On Aug 3, 10:50 am, Tomasz Nazar [EMAIL PROTECTED] wrote:
 Hi there!

 In short:
 Using Pylons 0.9.5 + SQLAlchemy + SaContext
 When running app or tests all is OK.
 But after change from pylons.database to sacontext for each 'nosetests
 test_*.py' I get a configuration error in addition: AttributeError:
 No configuration has been registered for this process or thread (full
 error below)

 In long:
 I am a new user to Pylons. I do not fully _yet_ understand the whole
 framework, but yet in the project we have managed to implement some
 quite nice functionality.
 I started a month ago with Pylons 0.9.5 and are not willing to upgrade yet.
 Nevertheless, initially I was using default pylons.database for
 SQLAlchemy, but a week ago I have tried successfully SAContext with
 0.9.5 and it works. No major problems overall.

 But when I run 'nosetests' for any test, then the test runs fine - all
 the SQLAlchemy objects are managed properly, transaction management,
 sqla sessions cool - but I always get additional 2 errors for each one
 test class (2 errors are the same). Here it is:

 error
 ==
 ERROR: test module yyy in F:\xxx\svn\trunk\portal\portal
 --
 Traceback (most recent call last):
   File 
 c:\programy\python\python24\lib\site-packages\nose-0.9.2-py2.4.egg\nose\suite.py,
 line 51, in run
 self.setUp()
   File 
 c:\programy\python\python24\lib\site-packages\nose-0.9.2-py2.4.egg\nose\suite.py,
 line 200, in setUp
 self.module = _import(self.moduleName, [self.path], self.conf)
   File 
 c:\programy\python\python24\lib\site-packages\nose-0.9.2-py2.4.egg\nose\importer.py,
 line 101, in _import
 mod = load_module(fqname, fh, filename, desc)
   File F:\xxx\svn\trunk\portal\portal\models\__init__.py, line 10, in
  ?
 sac.add_engine_from_config(None)
   File F:\xxx\svn\trunk\portal\portal\lib\sacontext.py, line 533, in
 add_engine_from_configconfig_key)
   File F:\xxx\svn\trunk\portal\portal\lib\sacontext.py, line 578, in
 parse_engine_optionsfor full_key in config.iterkeys():
   File 
 c:\programy\python\python24\lib\site-packages\PasteDeploy-1.3.1-py2.4.egg\paste\deploy\config.py,
 line 101, in __getattr__
 raise AttributeError(
 AttributeError: No configuration has been registered for this process or 
 thread

 --
 Ran 1 test in 2.438s

 FAILED (errors=2)
 /error

 Here is some details of configuration:
 -Pylons-0.9.5-py2.4
 -sqlalchemy-0.3.8-py2.4
 -nose-0.9.2-py2.4
 -Paste-1.4-py2.4
 -PasteDeploy-1.3.1-py2.4

 + manually downloaded sacontext.py (0.3.3)

 And part of my models/__init__.py:
 #From 'SQLAlchemy for people in hurry'
 import sqlalchemy as sqla
 from sqlalchemy.orm import mapper
 from portal.lib.sacontext import PylonsSAContext

 sac = PylonsSAContext()
 sac.add_engine_from_config(None)  # --- LINE 10

 #All the businness classes are here..
 from portal.models.domain import User

 users_t = sqla.Table('users', sac.metadata, autoload=True)
 #Etc...
 mapper(User, user_t)
 #Etc...

 The are no modifications to Pylons base classes, configurations or whatever.
 Just the necessary ones for using Mako.
 config/* are almost original except routing.py,
 lib/* the same..

 Any ideas?

 Tomasz Nazar

 --
   _i__'simplicity_is_the_key'__tomasz_nazar
   _ii'i_am_concern_oriented'JKM-UPR
   _iii__'patsystem.sf.net'___linux_user
   _Heaven__Fellows,_PPP__prevayler


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



routing setup: advice wanted

2007-09-26 Thread Max Ischenko
Hi,

I want to setup my url mappings so that the follows urls will work:

/admin/clients/ --  index method on ClientsController
/admin/clients/foobar --  foobar method on ClientsController
/admin/clients/123 --  'view' method on ClientsController, with id passed
in
/admin/clients/123;quux --  quux method on ClientsController, with id
passed in

After some trial runs I ended up with the following Routes setup code:

m.connect('admin_clients', '/admin/clients/:action',
controller='clients', action='index',
requirements=dict(action='[a-z].*'))
m.connect('admin_client', '/admin/clients/:id;:action',
controller='clients', action='view',
requirements=dict(id='\d+'))

Note the requirements arg -- without them it confuses the too, even though
the urls can always be differentiated with ;.

I wonder, if there is a way to simplify my routes code? Say, expressing
these two rules as a single rule.

Max.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Ajax upload -pylons based

2007-09-26 Thread voltron

Has anyone coded the backend pylons controller functions script for
swfupload(http://swfupload.mammon.se/) or jquploader(http://
www.pixeline.be/experiments/jqUploader/setup.php) ?

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: Ajax upload -pylons based

2007-09-26 Thread voltron

Great!! I am so tired of seeing php scripts attached everywhere :-)
please send it over

On Sep 26, 2:39 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Hiya,

 I wrote a quick blog entry on this yesterday actually. I can send you my
 sample project tonight if you like? Should probably have attached it to the
 blog entry thinking about it.

 http://jimmyg.org/2007/09/25/multiple-file-uploads-with-progress-mete...
 g-flash-8-and-javascript/http://jimmyg.org/2007/09/25/file-uploads-in-python/

 Cheers,

 James

 Original Message:
 -
 From: voltron [EMAIL PROTECTED]
 Date: Wed, 26 Sep 2007 12:09:09 -
 To: pylons-discuss@googlegroups.com
 Subject: Ajax upload -pylons based

 Has anyone coded the backend pylons controller functions script for
 swfupload(http://swfupload.mammon.se/) or 
 jquploader(http://www.pixeline.be/experiments/jqUploader/setup.php) ?

 Thanks

 
 mail2web.com - What can On Demand Business Solutions do for 
 you?http://link.mail2web.com/Business/SharePoint


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Pudge on Pylons 0.9.6

2007-09-26 Thread Yannick Gingras


Hi, 
I can't get pudge to work on 0.9.6.  I just did:

  easy_install -U pudge buildutil

and got:

  buildutils-0.3-py2.4.egg
  pudge-0.1.3-py2.4.egg

Now, I create a brand new pylons project and try to make some doc:

  paster create -t pylons dtest
  cd dtest
  python setup.py pudge

And all I get is:

  error: invalid command 'pudge'

Am I doing something wrong?

Anyway, this might not be such a problem after all because I find the
pudge generated doc to be quite ugly.  Maybe there is some other doc
system out there that might not be well integrated with pylons but
that will work and produce good looking doc.  I have asciidoc in mind
but maybe there is something better.

What do you all use for user documentation or your pylons projects?

-- 
Yannick Gingras

--~--~-~--~~~---~--~~
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: Pylons 0.9.5 + SAContext and nosetests gives additional warnings

2007-09-26 Thread Ben Bangert

On Sep 26, 2007, at 2:09 AM, Jim Musil wrote:


This is probably too late, but I had the same problem.

The problem is that tests are collected and tests/__init__.py runs
before any configuration is loaded and therefore cannot be referenced.
This makes it tough to test your db if you have connection variables
set in your test.ini files. Or sqlalchemy, which is looking for
configuration settings there.


Pylons 0.9.6.1 in addition to including the security fix for private  
methods, will include a nose plugin that ensures the app is loaded  
before scanning for doctests. This way doc tests will work fine with  
your models.


Cheers,
Ben

smime.p7s
Description: S/MIME cryptographic signature


AW: Displaying page elements based on AuthKit authentication?

2007-09-26 Thread Andrew Smart

 -Ursprüngliche Nachricht-
 Von: pylons-discuss@googlegroups.com 
 [mailto:[EMAIL PROTECTED] Im Auftrag von 
 [EMAIL PROTECTED]
 Gesendet: Mittwoch, 26. September 2007 16:40
 An: pylons-discuss
 Betreff: Displaying page elements based on AuthKit authentication?
 
 
 Hello,

Hi Wayne,

 
 Maybe I am missing something obvious, but I am using Pylons 
 with the AuthKit middleware and mako templates and I am 
 curious what the best method for controlling what elements 
 are displayed to the user based on their authentication is .. 
 should the logic exist in the template?
 Should the controller push down the element to the template? 
 An example would be changing the login form to an action menu 
 once the user is authorized.
 
 Right now I am pushing c.user_menu to the template (a list of 
 menu items based on permissions) to the template. This is an 
 empty value if they have no authentication, for an empty list 
 I display the login form else I display the users action menu.
 
 Best practices here? Alternative methods for accomplishing 
 this? Or is this the right way?

I had equal questions - how to aggregate a view in terms
of navigation links based on the user credentials and the
inner restrictions of the application. But there is no
common answer for this currently in the plyons world - AFAIK,
of course.

There is currently no best way - I'm writing currently
a navigator/view class set which deals with such issues
for myself, and I'm going to integrate the auth-stuff
also into it.

My approach is: the application (based on controllers) defines/
controlls what the users sees. The mako templates get this input
(like you did with c.user_menu) and have the job to create some
nice HTML out of it.

So if you change the templating (maybe because of a different 
layout, or a different visual navigation approach) it can be
done without having to change the way the controllers defines the
views. On the other hand you can easily change the what the
users will see in the controllers without having to change
the templates, or even without having to know how the navigation
will be rendered visually.

I'm willing to share my Nav-stuff - I'll create a wiki entry
for it in the next days.

Regards,
Andrew
 


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



AW: Displaying page elements based on AuthKit authentication?

2007-09-26 Thread Andrew Smart


 -Ursprüngliche Nachricht-
 Von: pylons-discuss@googlegroups.com 
 [mailto:[EMAIL PROTECTED] Im Auftrag von 
 [EMAIL PROTECTED]
 Gesendet: Mittwoch, 26. September 2007 16:40
 An: pylons-discuss
 Betreff: Displaying page elements based on AuthKit authentication?
 
 
 Hello,
 
 Maybe I am missing something obvious, but I am using Pylons 
 with the AuthKit middleware and mako templates and I am 
 curious what the best method for controlling what elements 
 are displayed to the user based on their authentication is .. 
 should the logic exist in the template?
 Should the controller push down the element to the template? 
 An example would be changing the login form to an action menu 
 once the user is authorized.

I forgot something: auth-kit is dealing only with authentication, 
Authorisation and access (AAA). It is not focused to help you with 
navigation - and I think this is the right approach. Seggregation of 
duties, seperation of code and stuff...

Regards,
Andrew


--~--~-~--~~~---~--~~
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: Mako %doc tags confuse HtmlFill parser

2007-09-26 Thread voltron

HtmlFill  returned my templates fine when I removed them . A pity
though, I dont like the HTML comments

On Sep 26, 9:32 pm, Philip Jenvey [EMAIL PROTECTED] wrote:
 On Sep 25, 2007, at 11:41 PM, voltron wrote:



  mako %doc tags ruin HTML when parsed by HtmlFill parser. I intended
  to use the doc tags instead of HTML comments because they dont render.

 I don't understand why they would pose a problem when htmfill is
 generally called on rendered templates.

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



Anti-cacheing headers in Pylons

2007-09-26 Thread voltron

How does one generate anti-cacheing headers in Pylons?

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
-~--~~~~--~~--~--~---



Setting the content type in Pylons 0.9.6

2007-09-26 Thread alecf

I'm trying to render some Atom feeds with Pylons -
I've got a genshi template that more or less renders the atom feed,
but I need to return it as application/atom+xml

For the life of me I can't figure out how the new global response
object works - setting content_type has no effect.. my controller
looks something like:

response.content_type = application/atom+xml
response.content = render(genshi-xml, atom-feed)

(I had to write my own 'genshi-xml' engine plugin wrapper for Genshi,
because Genshi's default requires the file extension to be .html, but
that's a whole other story...)

Alec


--~--~-~--~~~---~--~~
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: Anti-cacheing headers in Pylons

2007-09-26 Thread James Gardner

You can edit your config/middleware.py file so the end of it looks like 
this:

 ...
 javascripts_app = StaticJavascripts()

 class NoCache(object):
 def __init__(self, app):
 self.app = app
 def __call__(self, environ, start_response):
 def sr(status,headers,exc_info=None):
 headers.append(
 (
 'Cache-Control',
 'no-cache, no-store, must-revalidate'
 )
 )
 return start_response(status,headers,exc_info)
 return self.app(environ, sr)

 app = NoCache(app)

 app = Cascade([static_app, javascripts_app, app])
 return app


If you want to force everything to be refreshed, not just the 
dynamically generated pages you can wrap the whole app in the NoCache 
middleware.

Or you can do it from a controller action with:

response.headers['Cache-Control']='no-cache, no-store, must-revalidate'

James



voltron wrote:
 How does one generate anti-cacheing headers in Pylons?
 
 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: Setting the content type in Pylons 0.9.6

2007-09-26 Thread James Gardner

Hi Alec,

You need:

response.headers['Content-type'] = application/atom+xml
return render(genshi-xml, atom-feed)

James


alecf wrote:
 I'm trying to render some Atom feeds with Pylons -
 I've got a genshi template that more or less renders the atom feed,
 but I need to return it as application/atom+xml
 
 For the life of me I can't figure out how the new global response
 object works - setting content_type has no effect.. my controller
 looks something like:
 
 response.content_type = application/atom+xml
 response.content = render(genshi-xml, atom-feed)
 
 (I had to write my own 'genshi-xml' engine plugin wrapper for Genshi,
 because Genshi's default requires the file extension to be .html, but
 that's a whole other story...)
 
 Alec
 
 
  


--~--~-~--~~~---~--~~
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: Anti-cacheing headers in Pylons

2007-09-26 Thread voltron

Thanks!

On Sep 27, 12:39 am, James Gardner [EMAIL PROTECTED] wrote:
 You can edit your config/middleware.py file so the end of it looks like
 this:

  ...
  javascripts_app = StaticJavascripts()

  class NoCache(object):
  def __init__(self, app):
  self.app = app
  def __call__(self, environ, start_response):
  def sr(status,headers,exc_info=None):
  headers.append(
  (
  'Cache-Control',
  'no-cache, no-store, must-revalidate'
  )
  )
  return start_response(status,headers,exc_info)
  return self.app(environ, sr)

  app = NoCache(app)

  app = Cascade([static_app, javascripts_app, app])
  return app

 If you want to force everything to be refreshed, not just the
 dynamically generated pages you can wrap the whole app in the NoCache
 middleware.

 Or you can do it from a controller action with:

 response.headers['Cache-Control']='no-cache, no-store, must-revalidate'

 James

 voltron wrote:
  How does one generate anti-cacheing headers in Pylons?

  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: Setting the content type in Pylons 0.9.6

2007-09-26 Thread alecf

I think the only disappointing thing with that is the charset normally
gets stuck in there too, and I want to set that in another location...

I played around with it and I also was able to set
config['pylons.response_options']['content_type'] for a similar
effect.

Is this going a little too much behind-the scenes?

Alec



On Sep 26, 3:40 pm, James Gardner [EMAIL PROTECTED] wrote:
 Hi Alec,

 You need:

 response.headers['Content-type'] = application/atom+xml
 return render(genshi-xml, atom-feed)

 James

 alecf wrote:
  I'm trying to render some Atom feeds with Pylons -
  I've got a genshi template that more or less renders the atom feed,
  but I need to return it as application/atom+xml

  For the life of me I can't figure out how the new global response
  object works - setting content_type has no effect.. my controller
  looks something like:

  response.content_type = application/atom+xml
  response.content = render(genshi-xml, atom-feed)

  (I had to write my own 'genshi-xml' engine plugin wrapper for Genshi,
  because Genshi's default requires the file extension to be .html, but
  that's a whole other story...)

  Alec


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



https in qualified urls

2007-09-26 Thread Max Ischenko
Hi,

I'm using url_for with qualified=True option but for some reason it
generates urls with https prefix. Why it happens? Do I need to put
protocol=http into each and every qualified url_for invocation to prevent
it from happening?

Max.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---