translations and websetup

2007-04-06 Thread Wichert Akkerman

I'm creating a database in my websetup, so I have to import my models
there. Some of my models use translations, and as a result things
currently go boom:

  File 
/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Pylons-0.9.4.1-py2.4.egg/pylons/i18n/translation.py,
 line 57, in ugettext
return pylons.translator.ugettext(value)
  File 
/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste-1.3-py2.4.egg/paste/registry.py,
 line 125, in __getattr__
return getattr(self._current_obj(), attr)
  File 
/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste-1.3-py2.4.egg/paste/registry.py,
 line 177, in _current_obj
raise TypeError(
TypeError: No object (name: Translator) has been registered for this thread

I can't seem to find a way to register a translator for use in websetup.
Can someone point me in the right direction?

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

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



authkit form_result caching

2007-04-10 Thread Wichert Akkerman

the documented method to secure all methods in a controller is to wrap
it in authkit middleware. I'm doing that like this:

CreditController=authkit.authorize.middleware(CreditController(),RemoteUser())

however as soon as I do this I see form_result being cached.

The access pattern I have works like this: I have an index method which
can be accessed using either GET or POST. When a user POSTs to it and
later does a GET self.form_result is still set if the controller is
wrapped in the authkit middleware. 

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

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



unicode error

2007-04-20 Thread Wichert Akkerman

Using Pylons 0.9.5 with Kid I get a unicode error from formencode when
I have a non-ascii character in my template (copy; in this case).
Looking ath the data based to formencode kid returns the template
as a utf8-encoded string, while formencode (htmlfill.py
line 234) really wants a unicode string.

There is a slight documentation bug in formencode.htmlfill.render: the
docstring says the form parameter should be a string. Judging by the
rest of the code that should be a unicode string, not a plain string.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Pylon with Apache

2007-04-29 Thread Wichert Akkerman

There is also another way of integrating with apache:
http://www.rkblog.rk.edu.pl/w/p/mod_wsgi/

Wichert.

Previously Graham Dumpleton wrote:
 
 
 
 On Apr 28, 6:40 am, Cliff Wells [EMAIL PROTECTED] wrote:
  On Fri, 2007-04-27 at 07:36 -0600, Orr, Steve wrote:
   What are the advantages/disadvantages pros/cons to doing a proxy instead 
   of just usingmod_python?
 
  Typically, proxying is:
 
  1. easier to setup thanmod_python
  2. easier to upgrade Python (nomod_python/python version issues)
 
 Can you elaborate further on what the specific mod_python/python
 versions issues are? Note that I ask this to learn what the problems
 supposedly are and why it may be any more problematic than having to
 recompile any third party C extension modules for Python which you may
 have also installed into the Python site packages directory. Such
 feedback would be useful because although people grumble about this
 and use it as a reason against using mod_python, those same people
 never actually come over to the mod_python mailing list to describe
 the problems so that mod_python may if required be improved or so they
 may be corrected in their understanding as to how things work.
 
 FWIW, here are the specific issues that are already known about in
 respect of Python version issues when using mod_python. Do your
 specific problems match one of these or are they something else?
 
 First issue is not actually mod_python's fault and arises from fact
 that most binary Python distributions are not configured with --enable-
 shared. This means that no shared library is generated for Python,
 only a static library. The consequence of this is that the static
 objects have to be embedded within the mod_python.so Apache module. If
 one later upgrades Python to a newer patch revision of the same major/
 minor version but don't correspondingly recompile mod_python or obtain
 correct new binary version of it, you run the risk of problems because
 the core Python code you would be running would be older and not match
 the Python code files and Python C extension modules in the Python
 installation. Newer versions of mod_python will log warnings in the
 Apache error log when this problem occurs.
 
 The second issue is not completely mod_python's fault but arises from
 how Python works out where the installed Python code files and
 extension modules are installed. That is, how it works out what to set
 sys.prefix and sys.exec_prefix to. The way Python when being
 initialised does this is to find which 'python' executable is in its
 PATH and then from that try and work out where the library directory
 is. Problem with this is if you have multiple Python installations of
 the same major/minor version number but different patch revision
 installed in totally different locations, eg., /usr/bin and /usr/local/
 bin, it can find the wrong version as the Python version you want may
 not be that in the PATH for the user Apache is started as.
 
 With mod_python only way around this is to set PATH, PATHEXECUTABLE or
 PATHHOME environment variables in the environment of the user that
 Apache is started as. What should be done is for new directives to be
 added to mod_python called PythonExecutable and PythonHome which
 achieve the same thing so it can be done in Apache configuration
 instead. This would make it easier to resolve for those small
 percentage of people who have multiple Python installations on their
 system.
 
 Upgrading to a completely new major/minor version of Python without
 also using a recompiled version of mod_python will obviously also
 create lots of problems as it will continue to use an older version of
 Python, or may not even be able to find the installed mod_python
 Python code files anymore if old installation of Python was removed.
 
 The only other problem area is transitioning to a newer version of
 Python using the same system. That is, where you might want to be able
 to run applications using different versions of Python. To do this
 would mean running two distinct instances of Apache on the same box
 but with different installations of mod_python/Python. Preferably if
 doing this one should just perhaps use two different hosts.
 
 So except for the two quite specific issues noted above, are your
 problems perhaps really just an issue of dependency management,
 something that is going to occur for any software components and not
 just mod_python itself?
 
 Any feedback would be most appreciated so the real problems can be
 understood. Unfortunately when I have tried to dig into such claims in
 the past, there is usually dead silence, so can never find out what
 the real problems are so they can be addressed in mod_python if need
 be. :-(
 
 Graham
 
  3. doesn't require restarting Apache as often
  4. just as fast
  5. frees you from having to use Apache at all (other proxy solutions are
  available that are usually faster and lighter than Apache)
 
  Regards,
  Cliff
 
 
  

-- 
Wichert Akkerman [EMAIL

Re: Turbogears now based on Pylons!

2007-06-28 Thread Wichert Akkerman

Previously Michael Bayer wrote:
 On Jun 27, 6:42 pm, Ian Bicking [EMAIL PROTECTED] wrote:
  The way I see this working is something like (vaguely):
 
  def transaction_middleware(app):
   def wrapper(environ, start_response):
   manager = TransactionManager()
   environ['transaction.manager'] = manager
   try:
   app_iter = app(environ, start_response)
   except:
   manager.rollback()
   raise
   else:
   manager.commit()
 
  The manager is basically a container of *actual* transactions, and
  calling rollback or commit on it gets passed on to all the transactions
  in the manager.
 
 this is fine.  we're *really* starting to imitate J2EE in some ways.
 but its not a bad thing.

For what it's worth: Zope has a similar structure. The Zope publisher
starts a transaction when it receives a request and commits it when the
request processing has finished, unless an exception has been thrown or
someone did an explicit rollback. Rollback tends to be very rare so
it seems that it is not very useful to optimize for that case. The Zope
machinery allows you to add your own commit/rollback hooks, which is
used to tie SA into Zope.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Plugins for CMS

2007-07-13 Thread Wichert Akkerman

Previously Jonas wrote:
 
 In AroundWord blog system we are thinking in developing several
 plugins realated to CMS for our project:
 
 * CMS tools
 slug, tags, comments, feeds, voting, ...
 
 * Input parser
 ReST, Markdown, plain HTML, TinyMCE, ...
 
 These plugins will be AroundWord independent, copyrighted to its
 author/s, and licensed under LGPL, MIT/X11, or New BSD (MIT is
 preferred over New BSD because is more simple).
 
 As any project of TurboGears or Pylons will be able to be plugged in
 since we will use ToscaWidges, we'll achieve that more people
 contribute and so its development will be faster. I hope that.
 
 Bruce Wang suggested the Trac's plugin architecture [1]. It's simple
 and straight, but powerful too. And I agree.
 
 [1] http://trac.edgewall.org/wiki/TracDev/ComponentArchitecture

It may be interesting to look at using zope.interface and zope.component
as well. Those provide a very powerful and yet simple component
architecture that have seen a lot wider use and testing than the trac CA.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Missing nose version on the cheeseshop breaks pylons

2007-08-03 Thread Wichert Akkerman

try using http://download.zope.org/ppix as index for setuptools. That
mirrors the data from the cheeseshop but should not hide older versions
and be a lot faster.

Wichert.

Previously tarmo wrote:
 
 Hi,
 
 I ran into the same problem, any workaround available?
 
 Thanks,
 Tarmo Lehtpuu
 
 On Aug 3, 10:33 pm, Jerry Seutter [EMAIL PROTECTED] wrote:
  Hi,
 
  I just tried installing Pylons using the directions on the Pylons
  website - it failed because nose version 0.9.2 is no longer available
  on the cheeseshop, and Pylons requires a nose version between 0.9.2
  and 0.9.9.  Is there any chance you can put this version back up on
  the cheeseshop?  I have the file in case you need it.
 
  Thanks,
 
  Jerry Seutter
 
 
  

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: splitting validate in two

2008-03-23 Thread Wichert Akkerman

Previously Ian Bicking wrote:
 Wichert Akkerman wrote:
  I'm trying to use @validate but it does not quite fit my needs.
  Especially the fact that it automatically calls htmlfill which fails to
  handle XHTML makes it a no-go.
 
 Can you give an example of the XHTML it breaks on?  This might not be a 
 difficult thing to resolve in htmlfill, but I'm not sure.

I submitted a bug to the formencode tracker on sourceforge with all the
details.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: setup-app not working for composite pylons app?

2008-03-24 Thread Wichert Akkerman

Previously Mike Orr wrote:
 
 On Fri, Feb 22, 2008 at 11:06 AM, Brian Granger [EMAIL PROTECTED] wrote:
   We have two pylons apps that we want to combine using a composite
   app.  One of our pylons apps has a database that needs to be setup
   using the standard 'paster setup-app' command.
 
 I have doubts about whether setup-app is really worthwhile.  An
 alternative is to make a scripts/ package in your application and run
 them with python -m.  Or you can get fancy and set up entry points
 to make them normal executables.

at this moment it still appears to be the documented way to do
application setup, so either there should be a new documented best
practice or this should be fixed. I just ran into the same problem
(although it appears to break differently now) so I'ld expect this to
be a fairly common issue.

 The problem with setup-app is it can only do one thing, and that thing
 may be wrong when copying an existing deployment or updating it.  For
 instance, you may have to create the database tables, or reset the
 data to an initial state, or add a column or modify its type without
 disturbing existing data.  Or you may have to reinitialize some tables
 but not others, or set up some data files, etc.  if setup-app took
 arguments it could handle all these cases, but it doesn't.

I get the imporession that you are talking about migration types of
usage here. That is a very different problem than initial application
setup and is indeed best served differently, most likely in a way that
is much closer tied to the specific application.

Initial setup is simple and predictable in most cases: create a
database, create some tables, load some initial data, maybe create a
file and directory or two. websetup/paster setup-app seems to be a good
standard way to do that.

Perhaps it can be extended with a flag to make it refuse to run if it
has been run before, which will prevent people from accidentily zapping
existing data.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: New SQLAlchemy tutorial

2008-03-24 Thread Wichert Akkerman

Previously Mike Orr wrote:
 I've put a new SQLAlchemy tutorial in the Pylons official docs.
 http://wiki.pylonshq.com/display/pylonsdocs/Using+SQLAlchemy+with+Pylons

Thanks for that tutorial. I'm running into a problem with database
creation though. After following all the steps in that tutorial and
running paster setup-app it aborts with a long traceback, ending in:

  File 
/Users/wichert/Development/attingo/capos/lib/python2.4/site-packages/SQLAlchemy-0.4.3-py2.4.egg/sqlalchemy/engine/strategies.py,
 line 80, in connect
  raise exceptions.DBAPIError.instance(None, None, e)
   sqlalchemy.exceptions.OperationalError: (OperationalError) unable to open 
database file None None

tracing through load_environment the database is setup correctly:

  - init_model(engine)
  (Pdb) p engine
  
Engine(sqlite:///Users/wichert/Development/attingo/capos/capos/database.sqlite)

but it then fails on the create_all code.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: New SQLAlchemy tutorial

2008-03-24 Thread Wichert Akkerman

Previously Wichert Akkerman wrote:
 
 Previously Mike Orr wrote:
  I've put a new SQLAlchemy tutorial in the Pylons official docs.
  http://wiki.pylonshq.com/display/pylonsdocs/Using+SQLAlchemy+with+Pylons
 
 Thanks for that tutorial. I'm running into a problem with database
 creation though. After following all the steps in that tutorial and
 running paster setup-app it aborts with a long traceback, ending in:
 
   File 
 /Users/wichert/Development/attingo/capos/lib/python2.4/site-packages/SQLAlchemy-0.4.3-py2.4.egg/sqlalchemy/engine/strategies.py,
  line 80, in connect
   raise exceptions.DBAPIError.instance(None, None, e)
sqlalchemy.exceptions.OperationalError: (OperationalError) unable to open 
 database file None None

That turned out to be my mistake: I was mixing an extra / in the
sqlalchemy.url line in my .ini file.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Auth and Auth

2008-03-29 Thread Wichert Akkerman

Previously Mike Orr wrote:
 AuthKit's author James Gardner says the architecture is sound, the
 outstanding bugs have been fixed, and the two substantial chapters in
 the Pylons Book space on the wiki have been audited for Pylons 0.9.6.
   Against this are 4-5 people on IRC and this list who have had bad
 experiences with AuthKit and think it should be thrown into the ocean.
  Their argument seems to be not that it doesn't work (the previous
 bugs have been fixed), but that you can write your own authentication
 in the time it takes to learn it.

There is an important lesson here: a very important, if not the most
important, factor for adaption of a tool such as AuthKit is the quality
of its documentation and how easy it is for complete newcomers to start
using it. I consider myself a reasonably experienced programmer and I
found myself overwhelmed by the complexity of the AuthKit documentation
and setup. If there was a single tutorial that said 'do A and B and
voila! your app is now protected' AuthKit would probably be much more
accepted. Instead there are two pages in the pylons book that try to
cover all of AuthKit, which means they introduce so much complexity that
my first response was 'my needs are very simple, I will look elsewhere'.
After actually using AuthKit since there were no good alternatives at
the time and I did not want to bother to write my own thing I still
think that.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: showing defaults / submitting form info

2008-04-06 Thread Wichert Akkerman

Previously Jonathan Vanasco wrote:
 
 i'm trying, without any luck, to fill a form with default values
 
 in my application we have
 
 ---
 class Form:
basic form validation
pass
 
 class Controller:
def index(self):
print form
 
 @validator
 def submit(self):
some advanced validation that is not appropriate to put in the
 form class
if errors:
self.form_errors{}= errors
return self.index()
 ---
 
 the issue i keep running into, is that i can't find a way to push any
 data from the request / untained info on the submit into a reprint of
 the index.

This is what I use with genshi:

from genshi import HTML
from genshi.filters import HTMLFormFiller

# Insert the form parameters back into the form
filler=HTMLFormFiller(data=params)
stream=HTML(result) | filler
return stream.render(method=xhtml)

formencode also has a htmlfill utility method you can use.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: CSRF Question

2008-04-19 Thread Wichert Akkerman

Previously Jonathan Vanasco wrote:
 
 neat bob.
 
 I kind of like how django hacked it as a middleware filter though...
 
 maybe i could take your code and push it into two decorators...
 
 @csrf_protect_form - set global that will regex forms and add tokens

A regexp can't detect if it is dealing with html or xhtml.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: is there a good way to stash a global var, that doesn't use g/app_globals

2008-04-29 Thread Wichert Akkerman

Previously Contact 42 wrote:
 what's wrong with a normal python module.


Thread safety.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

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



parameterized controllers

2008-05-18 Thread Wichert Akkerman

I seem to regularly run into a model where I would like to change how
controller instantiation happens. A quite common patern I see is that
you want to do something with a subitem of a model, for example manage
the tasks for a particular project. With standard pylons you can easily
setup a route for a URL like /customer/customer-id/task/task-id and
map that to CustomerController.task(self, customer_id, task_id), where
you lookup the Customer model and then the right task for that customer.
This is then quickly duplicated when you add contracts, invoices, etc.
There is repetition there: every action method will start with code
to find the correct customer, like this:

class CustomerController(BaseController):
def DoSomething(self, cust_id, id):
customer=meta.Session.query(Customer).get(cust_id)
...

def DoMore(self, cust_id, id):
customer=meta.Session.query(Customer).get(cust_id)
...

I wonder if it would be better if you could specify controller construction
parameters in the route. The route format could easily be extended so
support controller-parameters, for example by using @ instead of :. In
my example I could have a route like this: /:controller/@objid/:action/:id 
which would tell pylons to instantiate a controller with the objid parameter
(CustomerController(objid=123)) on which the action is called. Your code
would then look like this:

class CustomerController(BaseController):
def __init__(self, cust_id=None):
if cust_id is not None:
   customer=meta.Session.query(Customer).get(cust_id)

def DoSomething(self, id):
   

def DoMore(self, id):


this reduces repitition and makes it possible to do (more) common setup
work in the controller constructor.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: parameterized controllers

2008-05-18 Thread Wichert Akkerman

Previously Jonathan Vanasco wrote:
 
 i'm not sure if this is the same...
 
 i often do stuff like this:
 
 
 class coreObjectController:
 def do_stuff():
   Session.query( self.model_object ).blach
 def do_more():
   pass
 
 class aCrontroller( coreObjectController ):
self. model_object = class_a
 
 class bCrontroller( coreObjectController ):
self. model_object = class_b

I don't see what the link between this and my suggestion I'm afraid.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: parameterized controllers

2008-05-19 Thread Wichert Akkerman

Previously Aaron R wrote:
 I did something similar using the __before__  method
 
 class CustomerController(BaseController):
  def __before__(self):
  if 'cust_id' in request.environ['pylons.routes_dict']:
   cust_id = request.environ['pylons.routes_dict']
 ['cust_id']
   c.customer=meta.Session.query(Customer).get(cust_id)
  else:
   c.customer = None
 
  def DoSomething(self, cust_id, id):
  .
 
  def DoMore(self, cust_id, id):
 .
 
 
 The routes_dict looks like this:
 
 {'action': u'dostuff', 'controller': u'customert', 'id': u'123'}
 
 Hopefully that works.

It works and is indeed better. I still think my approach is nicer: it
does not require poking manually at the routes memory but provides a
clean interface.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Cross-Project code sharing...modules/plugins what does Pylons use?

2008-05-24 Thread Wichert Akkerman

Previously rcs_comp wrote:
 However, I have run across a show stopper for me with Pylons unless I
 have missed something in the documentation.  Does Pylons support some
 kind of module/plugin architecture that will allow me to develop plug-
 in functionality across Pylons projects?  What would be called in
 Django an app.

No: the way pylons is setup it will only look for controllers and
templates in a single package. That is not terribly hard to fix but I'm
not sure if that is a design goal for pylons.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Cross-Project code sharing...modules/plugins what does Pylons use?

2008-05-24 Thread Wichert Akkerman

Previously Jose Galvez wrote:
 how is this essentially different from tosco widgets? or just making a 
 python module that you put someplace in your python path for your pylons 
 app to find?

Because your add-ons may want to do things like add a new controller,
replace a template, etc.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

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



initialise session in functional test

2008-06-08 Thread Wichert Akkerman

Does anyone have tips or example code for getting some test data into a
(beaker) session so a controller that's being tested can pick that up?

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: initialise session in functional test

2008-06-12 Thread Wichert Akkerman

Previously Shannon -jj Behrens wrote:
 
 On Sun, Jun 8, 2008 at 3:36 AM, Wichert Akkerman [EMAIL PROTECTED] wrote:
  Does anyone have tips or example code for getting some test data into a
  (beaker) session so a controller that's being tested can pick that up?
 
 If I were in your shoes, I would do some variation of the following:
 
 * Put a password in your .ini file.
 * Create a controller method that checks whether the md5 of some query
 parameter matches the md5 of the password.  If so, it loads the
 session.

I don't want to add controller methods just to be able to run a
unittest. I want to either get some real data in or add some mocks
somewhere so I can test my controller in isolation.

I'm not trying to be difficult - I just don't want to turn a unittest
into an integration test.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: WSGI Fails ImportError: No module named deploy

2008-06-16 Thread Wichert Akkerman

Previously Mike Orr wrote:
 
 On Sun, Jun 15, 2008 at 8:40 AM, Chris [EMAIL PROTECTED] wrote:
 
  I'm trying to run a simple app through Apache via mod_wsgi. Following
  the directions at 
  http://wiki.pylonshq.com/display/pylonscookbook/mod_wsgi+and+workingenv.py
  I've gotten the simple helloworld app.wsgi file to work correctly.
 
 This needs to be updated for virtualenv, which is workingenv's
 successor.  Any volunteers?

As an alternative you can also use zc.buildout with
collective.recipe.modwsgi which is possibly simpler to setup and allows
for better control over your environment.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

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



best practices for static resources

2008-06-16 Thread Wichert Akkerman

I am trying to figure out what the best practices for dealing with
static resources such as CSS, Javascript and images are. With a
default pylons setup every request goes through two StaticURLParser
instances and files returned by them do not get any caching headers.
This is very practical for development but not ideal for a deployment
For a deployment it would be nice to be able to serve static resources
from apache or nginx.

How do others do that? Do you use url_for to generate a URL for those
static resources and have that return a non-paster/pylons URL for
deployment environments and use the StaticURLParsers when running in
in development mode? If so, how did you set that up? 

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: best practices for static resources

2008-06-17 Thread Wichert Akkerman

Previously Cliff Wells wrote:
 On Mon, 2008-06-16 at 13:03 +0200, Wichert Akkerman wrote:
  I am trying to figure out what the best practices for dealing with
  static resources such as CSS, Javascript and images are. With a
  default pylons setup every request goes through two StaticURLParser
  instances and files returned by them do not get any caching headers.
  This is very practical for development but not ideal for a deployment
  For a deployment it would be nice to be able to serve static resources
  from apache or nginx.
  
  How do others do that? Do you use url_for to generate a URL for those
  static resources and have that return a non-paster/pylons URL for
  deployment environments and use the StaticURLParsers when running in
  in development mode? If so, how did you set that up? 
 
 I usually just setup Nginx to handle whatever location my static content
 is at.  It doesn't matter if Routes is setup to handle that location as
 the request never reaches Pylons.

How do you do that during development? Do you hardcode /public/ paths
for static resources everywhere?

I'm starting to think that a best practice setup is something like:

- instead of dumping static resources in / as currently done always
  put the in a private place, similar to how webhelper put its
  javascript files in /javascript/

- setup a separate route for static resources and always use url_for to
  them. I'm not entirely sure routes supports this at the moment.
  
- setup a URLMap in development.ini so you can run the whole site with
  just paster

- for production use a dedicated webserver to serve resources, possibly
  running on another host(name) even

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Plyons WSGI on Apache2.2

2008-06-17 Thread Wichert Akkerman

Previously Graham Dumpleton wrote:
 Read:
 
   http://code.google.com/p/modwsgi/wiki/ConfigurationIssues
 
 Not sure why you want run a single thread. From memory would only want
 to do that if trying to attach gdb to daemon process and debug at C
 code level.

I tried to run with a single thread for a bit since egg:Paste#evalerror
complained it doesnot work in a multi-thread environment, but it turns
out it still complains even if you limit mod_wsgi to one thread. 

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Plyons WSGI on Apache2.2

2008-06-17 Thread Wichert Akkerman

Previously Graham Dumpleton wrote:
 Is Paste#evalerror the same as EvalException or something different?

It's an entry point which maps to
paste.evalexception.middleware.make_eval_exception which indeed sets up
EvalException.

Looking at the code I must have misremembered: it does not support a
multi-process environment, but does support multi-threading.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: best practices for static resources

2008-06-17 Thread Wichert Akkerman

Previously Antonio Beamud Montero wrote:
 
 
 El mar, 17-06-2008 a las 04:33 -0700, Cliff Wells escribió:
  On Tue, 2008-06-17 at 10:36 +0200, Wichert Akkerman wrote:
   Previously Cliff Wells wrote:

I usually just setup Nginx to handle whatever location my static content
is at.  It doesn't matter if Routes is setup to handle that location as
the request never reaches Pylons.
   
   How do you do that during development? Do you hardcode /public/ paths
   for static resources everywhere?
  
  Actually, I never use webhelpers.  I generally use hardcoded paths in my
  template and map them in the webserver, but don't see what the issue
  would be when using webhelpers.  I don't see the whole process as being
  very complicated (nor any need to make it complicated).
 
 Well, it can be complicated, for example, you are developing with paster
 in the url localhost:5000/
 But, in production, your web is served under
 http://mydomain.com/cool/things/...

And then you want to scale up even further and have to offload static
resources to another machine. You don't want to have to edit all your
templates to do that.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Reddit open sources their site pylons implementation

2008-06-19 Thread Wichert Akkerman

Previously Jonathan Vanasco wrote:
 
 This is really great!
 
 We've been working on OpenSourcing a bunch of our stuff, and its nice
 to see some overlap on some things... and find inspiration on others.
 
 Dalius-
 Do you know the python OpenID libraries well?  Prerhaps I could
 convince you to help us with an openid plugin for our project ;)

They're quite simple - it shouldn't be hard to implement OpenID support
yourself.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Testing with the session object

2008-06-28 Thread Wichert Akkerman

Previously Mike Orr wrote:
 
 On Sat, Jun 28, 2008 at 7:19 AM, Jonathan Vanasco [EMAIL PROTECTED] wrote:
 
 
  On Jun 28, 7:18 am, Shannon -jj Behrens [EMAIL PROTECTED] wrote:
 
   * Use one action to put something into the session and then another
  to make use of the session.  It's a work flow.
 
  I've always thought that Pylons should have something that does that.
 
 Well, JJ is right in a way.  The session is supposed to hold state
 between web requests.  So it makes sense that you'd set it up via web
 requests.  Just like an application that requires login; you have to
 do the login request at the beginning of each test.
 
 But I can also see the point of giving Pylons some premade session
 data, like a test with premade database data.  In Mechanize you can
 precreate a CookieJar and seed it with cookies, and pass that to your
 fake browser object.  You can also save the cookie jar to a file and
 reuse it later.

I found that when you are writing unit tests it is essential to be able to
stuff data into session, c and request. I'm using a base class for
unittests which looks like this:

from unittest import TestCase
from paste.registry import Registry
import pylons
from pylons.util import ContextObj
from pylons.controllers.util import Request


class PylonsTestCase(TestCase):
A basic test case which allows access to pylons.c and pylons.request.


def setUp(self):
self.registry=Registry()
self.registry.prepare()

self.context_obj=ContextObj()
self.registry.register(pylons.c, self.context_obj)

self.request_obj=Request(dict(HTTP_HOST=nohost))
self.registry.register(pylons.request, self.request_obj)


it probably isn't difficult to add session support to that.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Testing with the session object

2008-06-29 Thread Wichert Akkerman

Previously Marin wrote:
 On Jun 28, 8:01 pm, Wichert Akkerman [EMAIL PROTECTED] wrote:
  I found that when you are writing unit tests it is essential to be able to
  stuff data into session, c and request. I'm using a base class for
  unittests which looks like this:
 
  from unittest import TestCase
  from paste.registry import Registry
  import pylons
  from pylons.util import ContextObj
  from pylons.controllers.util import Request
 
  class PylonsTestCase(TestCase):
  A basic test case which allows access to pylons.c and 
  pylons.request.
  
 
  def setUp(self):
  self.registry=Registry()
  self.registry.prepare()
 
  self.context_obj=ContextObj()
  self.registry.register(pylons.c, self.context_obj)
 
  self.request_obj=Request(dict(HTTP_HOST=nohost))
  self.registry.register(pylons.request, self.request_obj)
 
  it probably isn't difficult to add session support to that.
 
 I am trying to add the session (StackedObjectProxy) but you code does
 not  'compile'. There is no Request in pylons.controllers.util
 Have you typed it correctly?

It's there in Pylons 0.9.7beta5. No idea where previous versions put it,
but a quick grep should tell you.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: best way to get user's IP address in pylons?

2008-07-03 Thread Wichert Akkerman

Previously Chris AtLee wrote:
 
 On Thu, Jul 3, 2008 at 1:04 PM, kevin [EMAIL PROTECTED] wrote:
 
  hello,
 
  hope all is well.
 
  i'm wondering what the best way to get a user's IP address is?
  because the reCaptcha verification wants the remote IP.
 
  I know I can get request.host and socket.gethostbyname can resolve
  host to IP.
 
  but i'm looking for something else first, maybe a Pylons/WSGI field
  for IP, because resolution is relatively expensive at scale.
 
  thanks,
  kevin
 
 request.environ['REMOTE_ADDR'] does it for me

Possibly better:

  request.environ.get(X_FORWARDED_FOR, request.environ[REMOTE_ADDR])

that handles requests coming in from a proxy server as well. You may
want add some extra checking to see if REMOTE_ADDR really is a proxy
server before trusting the X-Forwarded-For header.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: best way to get user's IP address in pylons?

2008-07-03 Thread Wichert Akkerman

Previously Jonathan Vanasco wrote:
 
 On Jul 3, 4:42 pm, Wichert Akkerman [EMAIL PROTECTED] wrote:
  Possibly better:
 
    request.environ.get(X_FORWARDED_FOR, request.environ[REMOTE_ADDR])
 
 maybe someone can make a middleware or pylons patch + config setting
 that migrates X_FORWARDED_FOR to REMOTE_ADDR

It should not migrate - there is real value in knowing both settings
separately.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: tests fail because of g

2008-07-07 Thread Wichert Akkerman

Previously Mike Orr wrote:
 
 On Mon, Jul 7, 2008 at 1:33 PM, Wichert Akkerman [EMAIL PROTECTED] wrote:
  What's wrong with using paste.loadapp to properly set 'g' for every
  test that needs it?  That way your test environment is the closest to
  the production environment -- which is the purpose of having tests in
  the first place.
 
  Unit tests want as little as possible of the full environment. And you
  want to be able to unit test code that uses things like g.
 
 Well, unit tests (as opposed to functional tests) should test the
 target routine as closely as possible, without the interference of
 something like 'g' which should be tested separately.  After all, a
 value on 'g' is the same as the value standalone.

You might want to unittest a method that uses g in some way. More
typically you may want to unit test something that stuffs data in c.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: WebHelpers 0.6 released

2008-07-13 Thread Wichert Akkerman

Previously Ian Bicking wrote:
 
 Christoph Haas wrote:
  On Freitag, 11. Juli 2008, Mike Orr wrote:
  On Fri, Jul 11, 2008 at 9:43 AM, rcs_comp [EMAIL PROTECTED] wrote:
  in html.tags the form function has 'POST' for the default method,
  which is invalid xhtml.  I changed it to:
 
  def form(url, method=post,...
 
  and all is well.
  Is it really?  Does the browser convert it to POST before sending the
  HTTP request?  Just want to make sure I don't break anything before
  lowercasing it (and all the other methods in the function).
  
  I second rcs_comp (/me donates his parent a few bucks to give him a real 
  name). I use method='post' everywhere in my code because uppercase 
  attributes aren't xhtml'ish. That reminds me that I wanted to open a 
  ticket for that one. :)
 
 Uppercase attribute... values?  What does XHTML care about the values? 
 Apparently the DTD does specify lower-case values.  XHTML is totally nutty.

I asked a designer friend of mine recently why he preferred XHTML over HTML. He
had a whole set of reasons (paraphrased and translated from Dutch):

1. XHTML = XML, which makes transformation from XML to XHTML with, for example,
   XSLT much simpler.
2. XHTML is consistent: all tags are closed instead. Unlike HTML, which is very
   inconsistent and thus harder to deal with. An important aspect here is that
   parent vs child relations in XHTML are always clear, which is critical
   when styling content.
4. XHTML works on all browsers and is downwards compatible with ancient
   browsers, so no reason not to use it.
5. XHTML supports JavaScript DOM manipulation much better
6. XHTML can be parsed by both javascript and server side-parsers as XML
   which makes it easy to process. Some JavaScript parsers can not handle
   old HTML at all
7. There no reason not to use XHTML.


Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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 on Google App Engine

2008-07-21 Thread Wichert Akkerman

Mike Orr wrote:
 On Mon, Jul 21, 2008 at 12:02 AM, Wichert Akkerman [EMAIL PROTECTED] wrote:
 Previously Mike Orr wrote:
 Of course, that will diminish Mako's amazing speed.  It remains to be
 seen how much of a difference it makes.  Perhaps down the road Mako
 can be patched to put cached templates in Datastore.  Cc'ing Mke Bayer
 for comments.
 It's certainly better than genshi, but I wouldn't call it amazing. There
 are some new kids on the block that are a lot faster. See for example
 http://hannosch.blogspot.com/2008/07/project-messerschmidt-vs-nkotb.html
 
 How did Genshi rate six times faster than Mako?  That doesn't sound
 plausable.  Genshi has to parse and render XML, and convert tokens to
 HTML.  Mako and Cheetah run compiled Python functions that build up a
 string.

You're reading the graph the wrong way around: it lists pages per second, 
not rendering time. In other words zope.pagetemplate is insanely slow and 
spitfire insanely fast.

 How does zope.pagetemplate work, and what makes it so fast?

I haven't looked at spitfire and z3c.pt internals at all. You can find their 
sources at http://code.google.com/p/spitfire/ and 
svn://svn.zope.org/repos/main/z3c.pt

  (PS. Did you mean to send this to the list?)

I forgot the cc indeed, I've added it now.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.


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



Plesae do not remove pylons releases

2008-08-23 Thread Wichert Akkerman

I noticed that 0.9.7beta5 was deleted from
http://pylonshq.com/download/0.9.7 and as a result several of my
deployments are now broken since they were pinned to that revision and
can no longer be installed now. So please: never delete a release after
uploading it. 

I notice 0.9.7rc1 appeared both there and on pypi but I can not find an
announcement or changelog for it. Can someone provide those?

Wichert.



-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Shutdown hook

2008-10-09 Thread Wichert Akkerman

Previously Mr.Rech wrote:
 
 Not sure about this (never tried), but Python Library Reference says:
 
 Note: the functions registered via this module are not called when
 the program is killed by a signal, when a Python fatal internal error
 is detected, or when os._exit() is called.
 
 Since Ctrl+C sends a SIGINT to your server process, I don't think
 atexit registered function will be executed.

You can setup a signal handler for SIGINT.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Freezing a Pylons app

2008-10-10 Thread Wichert Akkerman

Previously Christopher Barker wrote:
 So, is there a way to turn off the use of pkg_resources in paste?

No, paste relies on it to handle entry points in various places. That is
a very popular pattern that more and more things are starting to use.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

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



Beaker info

2008-10-10 Thread Wichert Akkerman

Beaker seems to be very little documentation online, so hopefully
someone can help me out here.

I am looking at caching the results of things like expensive function
calls and database queries, and beaker seems to be usable as a caching 
system. What I can't seem to find is how to conveniently handle
per-request and forever-lasting caching. In Zope I can do this:

from plone.memoize import forever
from plone.memoize import view

@forever.memoize
def expensive_stuff():
The result of this function is cached forever, with the function
and its argument as cache keys.

@view.memoize
def expensive_stuff():
The result of this function is cached during this request only,
with the function and its argument as cache keys.


as far as I can see there is no direct alternative for beaker, is that
correct?

Wichert.
 
-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Freezing a Pylons app

2008-10-10 Thread Wichert Akkerman

Previously Mike Orr wrote:
 
 On Thu, Oct 9, 2008 at 11:23 PM, Wichert Akkerman [EMAIL PROTECTED] wrote:
 
  Previously Christopher Barker wrote:
  So, is there a way to turn off the use of pkg_resources in paste?
 
  No, paste relies on it to handle entry points in various places. That is
  a very popular pattern that more and more things are starting to use.
 
 Popular, but it's still on unstable ground because Setuptools isn't
 built into Python yet,.  This is just one of a series of problems
 people have when installing Pylons.  It's worth remembering that there
 aren't many packages that depend on others, much less a multilevel
 dependency -- Pylons and TurboGears are about it.

The zope libraries are much larger and have much more (too many)
dependencies than Pylons and Turbogears, by several factors.

 Unfortunately that puts the onus on us to either fix the Setuptools
 problems ourselves, complain to the developers, or make Pylons/Paste
 less dependent on Setuptools.

What exactly are 'the setuptools problems'? Entry points and namespaces
are very practical and I wouldn't want to loose them. All the
installation and index-handling logic in setuptools is probably best
replaced.

 The whole idea of importing an application by entry point when you
 already know what the module is called and it's already been installed
 is kind of funny.  But in this case, the problem seems to be not entry
 points or namespace packages but pkg_resources.require.
 
 The purpose of pkg_resources.require, according to its documentation,
 is to guarantee version dependencies are satisfied and to activate
 eggs that are along sys.path but not on it.  I tend to think this
 whole concept is obsolete now that you can install different versions
 into different virtual environments.  I don't know of anybody who has
 installed multiple versions of a package into the same directory, and
 then had two applications that each used pkg_resources.require to
 activate a different version.  On the other hand, I know people who
 have hesitated to use pkg_resources.require because that makes the
 application or library depend on Setuptools.

I've never used multi-version support or resources.require, and I agree
that we have better tools now. I think a problem of setuptools is that
it does too many things, and not all of them very well:

- namespace handling
- entry points
- multi-version egg installation
- building and uploading eggs
- egg installation
- remote package searching and downloading

pyinstall already does a better job at the last two. A simple
implementation of the first two in the standard library would go a long
way to improving things.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Putting DELETE's params into request.POST

2008-10-17 Thread Wichert Akkerman

Previously Sok Ann Yap wrote:
 On the other hand, if we look into httplib2's source code, which I
 supposed is everyone's favorite http client library, Joe Gregorio
 doesn't make any distinction between POST and DELETE. You can verify
 that by using httplib2 to send a DELETE request with body to a simple
 wsgi app that echoes back wsgi.input.

Probably because that was just easier. I can not imagine what the
semantics for a body for DELETE would be. What information would you
want to send to something that you are deleting?

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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 and Python 2.6 (Was: Re: go-pylons.py broken on Python 2.6 in Windows?)

2008-11-19 Thread Wichert Akkerman

Previously Mike Orr wrote:
 
 On Tue, Nov 18, 2008 at 12:22 AM, Lawrence Oluyede [EMAIL PROTECTED] wrote:
 
  On Tue, Nov 18, 2008 at 8:35 AM, Eric Ongerth [EMAIL PROTECTED] wrote:
 
  Correction: the point at which easy_installing Pylons errored out was
  during the installation of simpleJSON.  So it never reached the point
  of installing paste, pastescript, pastedeploy etc.
 
  Hey, I thought Python 2.6 includes the former simpleJSON as the new
  json module.  No?
 
  It does: http://docs.python.org/library/json.html
 
 It does but I doubt Python provides sufficient egg-info data for
 easy_install to know the dependency is not needed.

It can: setup.py is just python, so you can put conditional code in
there that checks the python version and modifies install_requires
accordingly. You need to do the same thing for the uuid module as well.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: simplejson install error, need help

2008-11-25 Thread Wichert Akkerman

Previously Mike Orr wrote:
 
 On Tue, Nov 25, 2008 at 2:35 PM, Ben Bangert [EMAIL PROTECTED] wrote:
  On Nov 25, 2008, at 12:43 PM, Mike Orr wrote:
 
  Is it possible to limit a dependency to certain versions of Python?
 
  It should be. Setup.py is just a Python file, I don't see why I can't test
  the Python version and toggle the dependencies.
 
 Aren't the dependencies stored in the egg_info files and reparsed when
 you call pkg_resources.require()?  Otherwise I don't see how it could
 do its cascade of dependency checking when you load the application
 egg, because setup.py isn't available at that point.

It works with source eggs since that python is run during dependency
determination, and for binary eggs since those are python
version-specific.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Pyjamas : Python - JS

2008-12-06 Thread Wichert Akkerman

Previously Eric Ongerth wrote:
 I have heard that the more you try to make Javascript behave like
 Python, the more you end up hating Javascript -- but that says nothing
 about Javascript itself.  Javascript is really a different language,
 with different strengths.  Perhaps the best plan is to use Javascript
 for its strongest points (for example instant-turnkey use of JSON,
 totally anonymous objects, function mutability, etc.) and do your more
 Pythonic tasks in Python.  Pylons makes it quite easy to leave as much
 of your logic as you wish in your controllers and keep your client-
 side view code very very thin.  Especially if you use a lightweight,
 concise JS framework like jQuery to help keep things readable and
 organized.
 
 That still leaves the case of the programmer who says, I want to keep
 as much logic as possible on the client side to ease my server load,
 but I hate Javascript.  In that case I don't have any good advice.

Choose a new carreer :)

 The claim that Javascript become[s] quickly unreadable for even
 medium-sized applications really reflects only on the individual
 programmer/developer and not on the language, honestly.  Javascript
 does not deserve to be compared to (e.g.) php, an unruly beast that
 literally encourages a mess.  Javascript is, at worst, neutral with
 respect to organization; at best it embodies the heights of
 abstraction, encapsulation, and readability.  It's all up to you.

A problem with javascript is that most people using it never get beyond
writing tiny bits of code to perform a single effect on a page. With new
frameworks making that even simpler that is even more true now than it
was a few years ago. But once you get beyond that you will indeed see
that javascript is a very nice and fun language.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Pyjamas : Python - JS

2008-12-06 Thread Wichert Akkerman

Previously Kless wrote:
 On 6 dic, 03:22, Eric Ongerth [EMAIL PROTECTED] wrote:
  But if you don't like Javascript, you have plenty of company.
  Including myself somewhat recently before I studied it more thoroughly
  and started trying harder with it ;-)
 
 Well, I hope that any day Lua can be embedded in the browser. I'm not
 the only person that think about it, and nobody should doubt about its
 better performance [1].

Unfortunately in the world of browsers you can not use something until
enough browsers support it. That is why we are still bound by the
capabilities of IE6 even now.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Django or Pylons - comparison details

2008-12-08 Thread Wichert Akkerman

Previously Alex Marandon wrote:
 
 2008/12/6 zunzun [EMAIL PROTECTED]:
  Seems like I should use Django?  Or should it be Pylons instead?
 
 Here is the advice of an average programmer with no emotional
 involvement in any of these projects.
 
 I think it depends on your background. The Pylons ecosystem is very
 powerful but it's quite complex and not really suitable for beginners.
 If it's going to be the first web framework you use, you should
 probably stick with Django or even better Rails.

grok might also be a good choice. I'm not quite sure of repoze.bfg is
quite there yet, but it is shaping up to be another excellent candidate
as well.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Django or Pylons - comparison details

2008-12-08 Thread Wichert Akkerman

Previously Ian Bicking wrote:
 
 Wichert Akkerman wrote:
  Previously Alex Marandon wrote:
  2008/12/6 zunzun [EMAIL PROTECTED]:
  Seems like I should use Django?  Or should it be Pylons instead?
  Here is the advice of an average programmer with no emotional
  involvement in any of these projects.
 
  I think it depends on your background. The Pylons ecosystem is very
  powerful but it's quite complex and not really suitable for beginners.
  If it's going to be the first web framework you use, you should
  probably stick with Django or even better Rails.
  
  grok might also be a good choice. I'm not quite sure of repoze.bfg is
  quite there yet, but it is shaping up to be another excellent candidate
  as well.
 
 Grok over Pylons?  I don't think Grok is really any less complex.  Doing 
 basic stuff isn't particularly hard in Pylons, is it?  There's no reason 
 you have to use FormEncode, AuthKit, or any of those other pieces unless 
 you want to, and if you are beginner to Python or web development you 
 might off avoiding those pieces and just writing your own ad hoc code.

grok is much more pluggable than pylons and has more documentation
available (especially if you also consider all zope documentation that
works for grok apps as well).

In terms of complexity for simple apps I don't think grok and pylons
differ much.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Django or Pylons - comparison details

2008-12-09 Thread Wichert Akkerman

Previously cropr wrote:
 I don't use FormEncode.  It is based on a very common design mistake
 made by a lot of programmers, who think one can better generate html
 from code.  When a graphical artist designs the layout of a web page,
 he uses tools who speak html, css and javascript, but no python (or
 Perl, Java, C++, ...).

While I agree FormEncode is very far from ideal, your argument does not
make sense to me. FormEncode does not generate markup at all unless
you explicitly tell it to. I do exactly what you describe: hand-written
markup written by a designer, with FormEncode on the backend only
doing decoding and validation.

Wichert.


-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Deploying Pylons project

2008-12-11 Thread Wichert Akkerman

Previously Pavel Skvazh wrote:
 Can you please point me in the direction the real world pylons apps
 are deployed? I tried mod_wsgi but couldn't get it running. Was a
 while ago. Probably there's a nice tutorial availible.

Personally I use mod_wsgi and deploy the application in a zc.buildout
environment using collective.recipe.modwsgi. That gives me an easy to
manage and predictable setup.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: buildout vs virtualenv for pylons and/or other wsgi apps?

2008-12-15 Thread Wichert Akkerman

Previously Mike Orr wrote:
 
 On Sun, Dec 14, 2008 at 8:38 PM, Iain Duncan iaindun...@telus.net wrote:
 
  Hi folks, I totally do not want to start a flame war here, but was
  wondering if people could give me their reasons for preferring buildout
  or virtualenv for automated builds of pylons apps or other wsgi apps.
 
 Virtualenv is more popular because it follows traditional Python usage
 for the most part.  You install packages interactively  and can change
 your mind at any time.  Buildout's configuration recipes are hard for
 many people to memorize, and it's more suited to situations where you
 know ahead of time exactly which libraries you'll need   You can
 change the configuration and rebuild the environment from scratch, but
 it's not as easy as installing an experimental package, trying it out,
 and then uninstalling it if you don't like it.So with virtualenv you
 can use the same tools for development as you use for deployment,
 whereas buildout is more of a deployment-only thing.

I do not fully agree with that: I use buildout for development all the
time. One very very important thing buildout adds is repeatability. I
can take my buildout and deploy it it any random other machine and be
sure that I will have the exact same environment afterwards, down to
exact package versions if needed.

Adding more librares with buildout is just as simple as with virtualend,
the pattern is just a bit different: instead of running easy_install you
add declare the new dependency in setup.py and re-run buildout. This
has the advantage of guaranteeing that your dependencies are declared
correctly: buildout will happily install everything you need and
uninstall everything you do not need to keep the system as clean as
possible.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: sqlalchemy objects in beaker cache

2008-12-17 Thread Wichert Akkerman

Previously Tomasz Narloch wrote:
 
 Andrey Plotnikov pisze:
  Hi,
 
  Is it safe to cache objects getting from sqlalchemy session query in
  beaker cache?
 

 I was done that but in that way I loose  connection with sqlalchemy 
 (Session) so

You can re-associate an object with a new session. See
http://www.sqlalchemy.org/docs/05/session.html#merging

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Flickr tutorial under 0.9.7?

2008-12-19 Thread Wichert Akkerman

Previously Matt Feifarek wrote:
 On Wed, Dec 17, 2008 at 6:19 PM, Ben Bangert b...@groovie.org wrote:
 
 
  I've updated the front page in the codebase which will soon be up at
  http://beta.pylonshq.com/, to properly reflect what's in Pylons 0.9.7.
  Should be deployed there shortly. I'm also getting most of the links fixed
  up so the site can be ready for launch with 0.9.7 final rather soon.
 
 
 Wow, Ben, the new site looks GREAT!
 
 Well done.

Indeed. And curious wants to know: is that a Pylons-powered CMS? It
looks like one..

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

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



category support for flash

2008-12-19 Thread Wichert Akkerman
Often it is very useful to have flash/status messages of several
different types, for example to be able to differentiate between
informational messages, warnings and errors. To do that I made
a simple extension to WebHelpers to add category support to its
Flash class. The change is completely backwards compatible, so if
you do not need categories you will never notice them.

Patch attached.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

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

diff -wurN WebHelpers-0.6.4/webhelpers/pylonslib.py WebHelpers/webhelpers/pylonslib.py
--- WebHelpers-0.6.4/webhelpers/pylonslib.py	2008-12-01 23:59:25.0 +0100
+++ WebHelpers/webhelpers/pylonslib.py	2008-12-19 20:52:10.0 +0100
@@ -9,6 +9,17 @@
 # modules should be importable on any Python system for the standard
 # regression tests.
 
+class Message(object):
+def __init__(self, category, message):
+self.category=category
+self.message=message
+
+def __str__(self):
+return self.message
+
+__unicode__ = __str__
+
+
 class Flash(object):
 Accumulate a list of messages to show at the next page request.
 
@@ -64,13 +75,15 @@
 def __init__(self, session_key=flash):
 self.session_key = session_key
 
-def __call__(self, message):
+def __call__(self, message, category=notice):
+if category not in [ warning, notice, error, success ]:
+raise ValueError(category)
 from pylons import session
-session.setdefault(self.session_key, []).append(message)
+session.setdefault(self.session_key, []).append((category, message))
 session.save()
 
 def pop_messages(self):
 from pylons import session
 messages = session.pop(self.session_key, [])
 session.save()
-return messages
+return [Message(*m) for m in messages]


Re: category support for flash

2008-12-19 Thread Wichert Akkerman

Previously Mike Orr wrote:
 
 On Fri, Dec 19, 2008 at 11:57 AM, Wichert Akkerman wich...@wiggy.net wrote:
  Often it is very useful to have flash/status messages of several
  different types, for example to be able to differentiate between
  informational messages, warnings and errors. To do that I made
  a simple extension to WebHelpers to add category support to its
  Flash class. The change is completely backwards compatible, so if
  you do not need categories you will never notice them.
 
 What kind of template do you use to display this?  Do you display all
 categories in the same place or in different places?

I show them in the same manner using self-healing messages (ie the same
kind of thing Growl does on OSX) with different styling for different
types of messages. I have the exact same interface in javascript which
I use to show messages returned by JSON calls or other notices.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: category support for flash

2008-12-20 Thread Wichert Akkerman

Previously Mike Orr wrote:
 
 On Fri, Dec 19, 2008 at 11:57 AM, Wichert Akkerman wich...@wiggy.net wrote:
  Often it is very useful to have flash/status messages of several
  different types, for example to be able to differentiate between
  informational messages, warnings and errors. To do that I made
  a simple extension to WebHelpers to add category support to its
  Flash class. The change is completely backwards compatible, so if
  you do not need categories you will never notice them.
 
  Patch attached.
 
 Opened a ticket for it.
 http://pylonshq.com/project/pylonshq/ticket/551
 
 As soon as 0.9.7 is out I can put it in a point release.
 
 If you could write a little howto about using it with Ajax and styling
 different categories, I'm sure it would help a fair number of people.

Certainly. Shall I put that text and the relevant javascript code in
that ticket as well?

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: category support for flash

2008-12-20 Thread Wichert Akkerman
) {
  button.removeClass(processing);
  ShowJSONResponse(data);
   },
   error: function(request, status, error) {
  button.removeClass(processing);
  ShowMessage(JSON call failed, error);
   }
  });

  return false;
  });
  });
   /script

This sets up a simple form which can be submitted normally by non-javascript
enabled browsers. If a user does hava javascript an AJAX call will be made
to the server and the result will be shown in a message. While the call is
active the button will be marked with a *processing* class.

The server can return a message by including a ``message`` field in its
response. Optionally a ``message_category`` field can also be included
which will be used to determine the message category. For example::

@jsonify
def handler(self):
   ..
   ..
   return dict(message=uSettings succesfully updated)




-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Opinion sought on example.com/username

2008-12-20 Thread Wichert Akkerman

Previously ED209 wrote:
 
 I'm planning on moving my users' profile pages to:
 
 example.com/:username
 
 but there has been some discussion amongst fellow developers that this
 might cause problems. I would have this route and subsequent routes as
 the last ones defined in my array of routes defenitions so any static
 routes would be matched first.

What if at some point in the future you need a new static route and a
user already registered with that username?

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

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



Unicode routes

2008-12-30 Thread Wichert Akkerman

I am trying to use unicode URLs and routes, but as far as I can see
routes does not quite support this at the moment: generating a route
with a non-ascii component fails (see
http://routes.groovie.org/trac/routes/ticket/85) and incoming requests
data is return as ASCII strings, not decoded unicode strings. This
contradicts the routes manual
(http://routes.groovie.org/manual.html#unicode) which appears to say
this should work fine.

Is anyone using unicode routes succesfully? Is there a trick that I'm
missing somewhere?

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Unicode routes

2008-12-30 Thread Wichert Akkerman

Previously Dalius Dobravolskas wrote:
 
 Hello,
 
  (see http://routes.groovie.org/trac/routes/ticket/85)
 The first impression about this ticket is that non unicode and non
 utf-8 encoded string was passed to routes. Most probably string was in
 some local encoding. That's only my impression. I wonder why this
 ticket is still open. Maybe routes authors think about using encoding
 prediction function from feedparser.

It's still open because I only just submitted it :)

I only pass unicode data to Pylons' redirect_to method, which calls
routes' url_for with only unicode parameters. Inside there everything is
encoded to utf-8 and then breaks.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Unicode routes

2009-01-02 Thread Wichert Akkerman

Previously Mark Ramm wrote:
  URIs can be UTF-8 with standard URL %-escaping - most browsers will
  decode (and encode) that automatically and show the unicode string in
  the address bar. That is especially important for languages with a
  non-latin character set: without this URLs are horrible for them.
 
 It would be awesome if routes supported this natively, even if only as
 an option, because lots of international URL's are much cleaner with
 it than they would be without it.

If you work with Asian companies it's pretty much a hard requirement
these days.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: running a controller method outside wsgi app

2009-01-18 Thread Wichert Akkerman

Previously Dalius Dobravolskas wrote:
 Hello,
 
 On Mon, Jan 19, 2009 at 7:44 AM, Roberto Allende ro...@menttes.com wrote:
 
  My motivation is to write a unit testing but even in other cases it
  could have sense to use a controller function isolated. Or at least in
  my case, this is the only restriction.
 
 If your intention is unit-testing do it Pylons way:
 http://wiki.pylonshq.com/display/pylonsdocs/Unit+Testing

That is not unit testing, that is functional testing.

If you want to unit test your controller and run it in isolation you
need to do a bit of setup work in your test case. I use this:

from unittest import TestCase
from paste.registry import Registry
import pylons
from pylons.util import ContextObj
from pylons.controllers.util import Request


class MockTranslator:
def ugettext(self, value):
return value


class PylonsTestCase(TestCase):
A basic test case which allows access to pylons.c and pylons.request.


def setUp(self):
self.registry=Registry()
self.registry.prepare()

self.context_obj=ContextObj()
self.registry.register(pylons.c, self.context_obj)

self.request_obj=Request(dict(HTTP_HOST=nohost))
self.registry.register(pylons.request, self.request_obj)

self.translator_obj=MockTranslator()
self.registry.register(pylons.translator, self.translator_obj)


If you just need database access you can use this:

class DatabaseTestCase(TestCase):
def setUp(self):
init_model(meta.engine)
meta.metadata.create_all(meta.engine)

def tearDown(self):
meta.Session.remove()
meta.metadata.drop_all(meta.engine)

and if you need both just inherit from both classes (and call setUp from both).

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: running a controller method outside wsgi app

2009-01-19 Thread Wichert Akkerman

Previously Dalius Dobravolskas wrote:
 On Mon, Jan 19, 2009 at 9:34 AM, Wichert Akkerman wich...@wiggy.net wrote:
 
  Previously Dalius Dobravolskas wrote:
   Hello,
  
   On Mon, Jan 19, 2009 at 7:44 AM, Roberto Allende ro...@menttes.com
  wrote:
  
My motivation is to write a unit testing but even in other cases it
could have sense to use a controller function isolated. Or at least in
my case, this is the only restriction.
  
   If your intention is unit-testing do it Pylons way:
   http://wiki.pylonshq.com/display/pylonsdocs/Unit+Testing
 
  That is not unit testing, that is functional testing.
 
 What's the difference except that your way might be a little bit
 more-efficient (like 20%)? I have seen several different ways of
 unit-testing pylons applications but basically they just help to do the
 same. What makes unit-testing functional testing in your opinion?

I run the controller method in isolation, which means:

- no other middleware that influences the result
- I can put stuf in c before I call the controller method, and
  introspect c afterwards
- no paste.fixture or WebTest influencing the result

with a unittest you want to call something in isolation, without
anything else being present. This is the only way to do that.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: running a controller method outside wsgi app

2009-01-20 Thread Wichert Akkerman

Previously Roberto Allende wrote:
 
 Wichert Akkerman escribió:
  Previously Dalius Dobravolskas wrote:

  Hello,
 
  On Mon, Jan 19, 2009 at 7:44 AM, Roberto Allende ro...@menttes.com wrote:
 
  
  My motivation is to write a unit testing but even in other cases it
  could have sense to use a controller function isolated. Or at least in
  my case, this is the only restriction.

  If your intention is unit-testing do it Pylons way:
  http://wiki.pylonshq.com/display/pylonsdocs/Unit+Testing
  
 
  That is not unit testing, that is functional testing.
 
  If you want to unit test your controller and run it in isolation you
  need to do a bit of setup work in your test case. I use this:

 
 Thanks a lot Wiggy, your mails were very helpful. Although, it seems 
 we're using different versions of Pylons (or i'm doing smt wrong) 
 because following your approach i also needed wsgiapp variables Buffet, 
 g and session at least.
 Just for the record, i'm using 0.9.6.2.

I'm using 0.9.7rc5, so there are bound to be some differences.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Webtest doesn't like 204 response with Content-Type header

2009-01-22 Thread Wichert Akkerman

Previously Chris Miles wrote:
 That is fair enough, but if the controller returns no content (None or  
  for instance) would it make sense to not set any Content-Type (and  
 related) headers?

At the very least you have to send a Content-Length: 0 header. If you
don't some proxies get confused and some browsers will spin forever
waiting for data to arrive.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: console tools

2009-01-23 Thread Wichert Akkerman

Previously Mike Orr wrote:
 On Fri, Jan 23, 2009 at 12:31 AM, cropr ruben.dec...@gmail.com wrote:
  I want to add some administrative console tools next to my 0.9.7
  Pylons application (e.g. a backup/restore).  I want to make use of
  some parameter settings in the development.ini or production.ini,
  but I don't need any wsgi stuff.  What is the best and easiest way to
  start up the console application
 
 The easiest way is to make a package for your scripts and run them
 with python -m; e.g.,
 
 python -m myapp.scripts.maintain   development.ini
 
 .  A more difficult way is to create paster plugins, but these will
 only be available if the current directory is the application.

I'm not sure it is more difficult. Here is an example :). Lets start
by creating a base class which does the basic Pylons setup work so
we can use Pylons tools in our commandline script:


from paste.deploy import loadapp, appconfig
from paste.script.command import Command

class PylonsCommand(Command):
group_name = 2style4you
min_args=1
max_args=1

def _SetupPylons(self):
Perform some magic setup work.
config_name = config:%s % self.args[0]
self.logging_file_config(self.args[0])
cwd=os.getcwd()
conf=appconfig(config_name, relative_to=cwd)
conf.update(dict(app_conf=conf.local_conf, 
global_conf=conf.global_conf))
self.wsgiapp=loadapp(config_name, relative_to=cwd)


We can now write the code for a simple command:

class MyExampleCommand(PylonsCommand):
summary=Summary shown in paster command listing
usage=\nExtra help text shown by paster help command

parser=PylonsCommand.standard_parser()

def command(self):
self._SetupPylons()
session=meta.Session()
# Do your work here
session.commit()


If you need to handle commandline arguments you register those with the parser
class variable:


class MyExampleCommand(PylonsCommand):
summary=Summary shown in paster command listing
usage=\nExtra help text shown by paster help command

parser=PylonsCommand.standard_parser()
parser.add_option(-u, --url, dest=url, default=None,
help=Use a different URL for our data)


The result is available via self.options.

To make your command available create an entry point so paster picks
it up. In your setup.py do something like this:

entry_points=
[paste.paster_command]
controller = pylons.commands:ControllerCommand
restcontroller = pylons.commands:RestControllerCommand

mycommand = myapp.commands:MyExampleCommand



You can now call it like this:

   paster mycommand development.ini


Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: FormEncode and International Languages

2009-01-27 Thread Wichert Akkerman

Previously Jonathan Vanasco wrote:
 fair on some points, i disagree with others.
 
 i'm in the US.  the formencode author seems to be as well.
 
 'internationalization' on most things seems to be limited to swapping
 in text.

There is internationalization and localization. You need to deal with
both.

 many of the checks, such as PlainText allow for only a subset of
 ascii.

Which subset would that be? Your example of é falls well outside of
ASCII.

 anything else trips an error.  short of making everything a unicode
 string (which I aready had done) - i'm specifically wondering how
 people are handling validating different form elements with these
 shortcomings.

Without concrete examples of things that break there is little we can
tell you.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: FormEncode and International Languages

2009-01-27 Thread Wichert Akkerman

Previously Gustavo Narea wrote:
 On Monday January 26, 2009 23:20:37 Jonathan Vanasco wrote:
  Our project is dealing with a lot of French writers typing things like
  é , which fails many formencode tests.

There is nothing special about the occasional accent in French: French
is much simpler than, for example, Chinese.

 Use UnicodeString instead of String:
 http://www.formencode.org/class-formencode.validators.UnicodeString.html
 
 I don't think the problem will be present on other validators -- at least I 
 guess so.

OneOf can't deal with non-ascii values if I remember correctly. I have
an open ticket in a project related to that.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Is Django more popular than Pylons?

2009-01-30 Thread Wichert Akkerman

Previously Gael Pasgrimaud wrote:
 
 Here it is:
 
 http://www.gawel.org/howtos/howto-install-pylons-with-buildout

It might be useful to document using collective.recipe.modwsgi as well.
That makes it trivial to use pylons with mod_wsgi from a buildout
environment.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: is there a way to call render with string teamplates?

2009-02-06 Thread Wichert Akkerman

Previously Dalius Dobravolskas wrote:
 Hello,
 
 On Fri, Feb 6, 2009 at 9:03 PM, Jonathan Vanasco jonat...@findmeon.comwrote:
 
 
  ie -- instead of passing in a file, passing in a string?
 
  the only way i can think of this right now is with a tmpfile, and i'd
  like to avoid that.
 
 I'm pretty sure that methods must return string and that's the only
 requirement on them.

Or string-like things. If you want to have the option of doing
transformation on the output rendering to XML doms and returning
repoze.xmliter (see
http://repoze.org/viewcvs/repoze.xmliter/trunk/README.txt?rev=2839view=auto)
instances is quite interesting.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: beaker_cache query_args when duplicate queries are in

2009-02-09 Thread Wichert Akkerman

Previously eleith wrote:
   My solution was to write my own decorator.
 could you share your decorator?

For what it's worth below is my variant of beaker_cache. It has
the advantage over the stock version that it works everywhere
instead of only for controller methods and will never try to
cache response headers. The only missing feature I can think of
is a simple way to add request headers to the cache key. That is
trivial to add, but not needed for my current projects so I haven't
added that.

Wichert.


def timed(expire=None, invalidate_on_startup=False, **b_kwargs):
Cache decorator utilizing Beaker. Caches action or other
function that returns a pickle-able object as a result.

Optional arguments:

``expire``
Time in seconds before cache expires, or the string never. 
Defaults to never
``invalidate_on_startup``
If True, the cache will be invalidated each time the application
starts or is restarted.

If cache_enabled is set to False in the .ini file, then cache is
disabled globally.


if invalidate_on_startup:
starttime = time.time()
else:
starttime = None

def wrapper(func, *args, **kwargs):
Decorator wrapper
enabled = pylons.config.get(cache_enabled, True)
if not asbool(enabled):
log.debug(Caching disabled, skipping cache lookup)
return func(*args, **kwargs)

key_dict=kwargs.copy()
key_dict.update(_make_dict_from_args(func, args))
cache_key =  .join([%s=%s % (k, v) for k, v in 
key_dict.iteritems()])

if hasattr(func, im_class):
namespace=%s.%s.%s % (func.__module__, func.im_class.__name__, 
func.__name__)
else:
namespace=%s.%s % (func.__module__, func.__name__)

my_cache = pylons.cache.get_cache(namespace, **b_kwargs)

def create_func():
log.debug(Creating new cache copy with key: %s, cache_key)
return func(*args, **kwargs)

return my_cache.get_value(cache_key, createfunc=create_func,
 expiretime=expire, starttime=starttime)

return decorator(wrapper)

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: beaker_cache query_args when duplicate queries are in

2009-02-11 Thread Wichert Akkerman

Previously Philip Jenvey wrote:
 I just applied a fix that now correctly handles eleith's issue with  
 duplicate query params, and always includes the function name  
 regardless of the key type specified. A fix was made about a month ago  
 to make it work everywhere (not just controller actions) again.

That has not yet made it into a release though. 

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: beaker_cache query_args when duplicate queries are in

2009-02-11 Thread Wichert Akkerman

Previously Philip Jenvey wrote:
 I just applied a fix that now correctly handles eleith's issue with  
 duplicate query params, and always includes the function name  
 regardless of the key type specified.

I think you also need to add the class name if you get a bound function:
you may very well have the same function name in multiple classes in
the same source file.

I also found another problem in the determination of the cache key:
default function arguments were not handled correctly. I've filed
that under http://pylonshq.com/project/pylonshq/ticket/568 along
with a fix.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: beaker_cache query_args when duplicate queries are in

2009-02-11 Thread Wichert Akkerman

On 2/11/09 11:12 PM, Philip Jenvey wrote:
 The class's name and module name are used for the cache's namespace, 
 which'll prevent clashes. For normal functions just the function's 
 module name is used for the namespace. Looking at this again maybe the 
 class name should be in the key instead of the namespace, but that's 
 not a big deal.

 By the time you read this an rc5 will likely be out with all these fixes.

Thanks! I'm looking forward to it.

Wichert.

-- 
Wichert Akkermanwich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/  It is hard to make things simple.


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



changes from rc4 to rc5

2009-02-12 Thread Wichert Akkerman

Is there a summary of the changes between rc4 and rc5?

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: changes from rc4 to rc5

2009-02-12 Thread Wichert Akkerman

Previously Ben Bangert wrote:
 - Beaker has been updated since the last release to fix several bugs  
 involving memcached, and how it stores session data

Does that mean that it is now possible to use memcache for beaker
sessions?

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

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



Caching in auth middleware

2009-02-13 Thread Wichert Akkerman

I have what I suspect is a reasonably common setup with a repoze.who
middleware for authentication, followed by transaction, routes, 
session, cache, registry manager and pylons middlewares.

In some cases you want to use a cache in authentication middleware
to prevent a SQL server hit on every request. Not completely
unexepctedly that immediately aborts on No object (name: cache) has
been registered for this thread. Strangely enough moving the
registry and cache middlewares up to be before the auth middleware
did not help: I got the exact same error.

Is there some magic in pylons that I'm missing?

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Caching in auth middleware

2009-02-13 Thread Wichert Akkerman

Previously Wichert Akkerman wrote:
 I have what I suspect is a reasonably common setup with a repoze.who
 middleware for authentication, followed by transaction, routes, 
 session, cache, registry manager and pylons middlewares.
 
 In some cases you want to use a cache in authentication middleware
 to prevent a SQL server hit on every request. Not completely
 unexepctedly that immediately aborts on No object (name: cache) has
 been registered for this thread. Strangely enough moving the
 registry and cache middlewares up to be before the auth middleware
 did not help: I got the exact same error.
 
 Is there some magic in pylons that I'm missing?

Of course just after sending this I figured out what it was. In case
this is useful for others: I solved this by adding a tiny bit of
middleware which registers the beaker cache.

class CacheRegisteringApp(object):
def __init__(self, app):
self.app=app

def __call__(self, environ, start_response):
from pylons.util import PylonsContext
import pylons

context = PylonsContext()
context.cache = environ[beaker.cache]
environ[2s4u.context] = context

registry = environ['paste.registry']
registry.register(pylons.cache, context.cache)

return self.app(environ, start_response)


Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Sqlalchemy: querying table in different functions gives different results

2009-02-17 Thread Wichert Akkerman

Previously Bryan wrote:
 
 1. Client calls login(), a new row is inserted in the token table.
 2. Client calls anotherFunction and the new row is not visible inside
 that function
 3. If I place a Session.commit() in anotherFunction, then I can see
 the row
 
 def login(self, user, pass):
' Create new login entry that gives the client an id to pass back
 to the server with each request
newtoken = Token()
Session.add(newtoken)
Session.flush()
Session.commit()
' Querying token table at this point shows all the tokens including
 the newly added one
 
 def anotherFunction(self, tokenId):
' If I list all rows in the token table at this point, the token
 created in login() is not visible
' If I have a Session.commit() call before I query however, the row
 is visible
 
 Other details:
 This is in an XMLRPCContoller.
 I have a scoped_session setup.
 
 Why is the second function looking at a stale version of the table?

Because you haven't flushed the changes to the database. This is well
documented in the SQLAlchemy documentation.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

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



pylonshq issue tracker disappeared

2009-03-09 Thread Wichert Akkerman

I'm not sure if anyone already noticed, but at the risk of repeating the
message: the issue tracker on pylonshq.com no longer works. All relevant
URLs return a 404.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

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



Beaker repeats every get

2009-03-09 Thread Wichert Akkerman

I was looking a bit at the memcache handling and noticed something odd:
all requests were repeated. For example:

11 get tostyle4you.lib.helpers_image_url_by_id·scale=scale56·id=None
11 sending key tostyle4you.lib.helpers_image_url_by_id·scale=scale56·id=None
11 END
11 get tostyle4you.lib.helpers_image_url_by_id·scale=scale56·id=None
11 sending key tostyle4you.lib.helpers_image_url_by_id·scale=scale56·id=None
11 END

I tracked the cause down to the get_value code from the Beaker
container, which looks like this:

222 def get_value(self):
223 self.namespace.acquire_read_lock()
224 try:
225 has_value = self.has_value()
226  - if has_value:
227 value = self.__get_value()

has_value and __get_value execute the same memcache get command, so a
cache hit always results in two identical queries.

Is there a reason Beaker can't roll has_value and get_value in one call?

Wichert.


-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: CMS/CMF on top of Pylons

2009-03-22 Thread Wichert Akkerman

Previously Mike Orr wrote:
 
 On Sun, Mar 22, 2009 at 5:29 AM, Raoul Snyman raoul.sny...@gmail.com wrote:
  You want a CMS? Use Drupal.
  You want to develop a web application? Use Pylons.
 
 Except that some applications may need a drop-in CMS for a section of
 the application.  You can supposedly embed Plone as a WSGI application
 but I don't know anybody who has tried it.

I think OpenPlans is doing that. You can run Plone 3 as a WSGI
application using Repoze, and Plone trunk is WSGI by default.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: What I've learned deploying pylons

2009-03-31 Thread Wichert Akkerman

Previously Wyatt Baldwin wrote:
 Questions: Which versions of supervisor and Python are ya'll using
 together? Should I go for supervisor 2.1 or 2.2b1 or 3.0a6 or ...?

Everyone is running 3.0a6 as far as I know.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: best ways to test ?

2009-04-10 Thread Wichert Akkerman

Previously Marius Gedminas wrote:
 Testing JavaScript is a bit harder.  I've seen how people integrate
 JavaScript *unit* tests into their py.test test suite, and I've used those
 ideas to define a unittest.TestCase subclass that spawns a browser
 window and drives it to run JsUnit-compatible test suites in Firefox or
 MSIE (under WINE, no idea if it would work in a real Windows OS).  This
 is not, however, a real integration test involving a real browser and
 your app.

Guido Wesdorp wrote a basic javascript emulator in Python which you can
use to test javascript in webpages from your python tests. I haven't
tried it, but at the concept is very interesting.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: updating database schema

2009-04-22 Thread Wichert Akkerman

Previously Ross Vandegrift wrote:
 
 On Wed, Apr 22, 2009 at 12:36:09AM -0700, Richard Jones wrote:
  Is there a way to access the database directly, so that I can manually
  re-jig the database.  Or do I have to provide an update script each
  time i change the schema?  (and if so, how?)
 
 I have a very low-tech solution.  I never use table reflection, all
 table layouts are explicit in my code.
 
 If I deploy a new version that requires schema changes and forget to
 update the database schema manuall, Pylons will throw me an error on
 any hit since the model won't be able to load. :)

Unless you change a constraint or index.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Plugin architecture

2009-04-28 Thread Wichert Akkerman

Previously Mike Orr wrote:
 The most difficult problem seems to be controllers, and the
 'controller_scan' argument in Routes which seems useless.  (We had to
 hardcode the controllers in our GUI BILS app because of some
 incompatibility with py2exe.)  Several people have asked how to have
 controllers in various packages and then pull in a selection of them.
 The simplest method is stub modules in the controllers directory that
 import the actual controllers.  But maybe we can find something more
 flexible.

If you decide to use zope.component a controller could be a named
utility. You could then register it like so:

  class BaseController(object):
  This is the standard Pylons base controller class.
  implements(IPylonsController)


  class MyController(BaseController):
  My very own controller.

  registerUtility(MyController, name=my_controller)

and Pylons could get a list of all utilities using something like this:

  controllers = getUtilitiesFor(IPylonsController)

This prevents the need to skin directories as currently happens, and
will allow you to put your controllers anywhere you want. You can also
selectively do the registerUtility calls, override already registered
controllers or remove controller registrations.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Plugin architecture

2009-04-28 Thread Wichert Akkerman

Previously Ben Bangert wrote:
 On Apr 28, 2009, at 2:43 PM, Wichert Akkerman wrote:
 
 If you decide to use zope.component a controller could be a named
 utility. You could then register it like so:
 
  class BaseController(object):
  This is the standard Pylons base controller class.
  implements(IPylonsController)
 
 
  class MyController(BaseController):
  My very own controller.
 
  registerUtility(MyController, name=my_controller)
 
 Yikes! :)

Why the yikes? The only change for a Pylons user is adding a single line
to register the controller. The interface that is used to manage the
registrations can be hidden in the BaseController class and internal
pylons logic - people may never need to know about it. This gives you a
lot of extra flexbility and pluggability, at the expense of asking
people to add a single line of code for each controller.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: app engine - state of play - 0.9.7

2009-05-03 Thread Wichert Akkerman

Previously Mike Orr wrote:
 
 On Sat, May 2, 2009 at 1:21 PM, Mike Orr sluggos...@gmail.com wrote:
  On Sat, May 2, 2009 at 6:34 AM, David Wilson
  david.wil...@entertainmentcloud.com wrote:
 
  I could not seem to get the debugger to work (vital for consideration)
  The problem with the interactive traceback seems to be due to the
  middleware disabling itself because of something in the runtime
  environment -- some situation that wasn't foreseen when the middleware
  was written.  We just have to figure out what exactly that is and
  patch the middleware to work with App Engine.
 
 Also, whatever broke is something recent, because the interactive
 traceback was working on App Engine a few months ago.

And it's not limited to GAE; interactive traceback hasn't work for me
for a month or so.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: app engine - state of play - 0.9.7

2009-05-06 Thread Wichert Akkerman

Previously Ben Bangert wrote:
 On May 3, 2009, at 7:42 AM, Wichert Akkerman wrote:
 
 And it's not limited to GAE; interactive traceback hasn't work for me
 for a month or so.
 
 It hasn't? What is happening instead?

I click on the + and get a javascript error.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: app engine - state of play - 0.9.7

2009-05-06 Thread Wichert Akkerman

Previously Ben Bangert wrote:
 On May 6, 2009, at 12:54 AM, Wichert Akkerman wrote:
 
 I click on the + and get a javascript error.
 
 What type of environment? What wsgi server? I can see why it wouldn't  
 work under GAE, since there's no guarantee you'll get back to the same  
 process (it relies on a *single* long-lived process to ask for more  
 debug info).

A pretty standard environment: OSX, python2.5, paster, pylons 0.9.7. It
could be a result of using chameleon.genshi, although it worked fine
with chameleon a while ago.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: app engine - state of play - 0.9.7

2009-05-11 Thread Wichert Akkerman

Previously Wichert Akkerman wrote:
 
 Previously Ben Bangert wrote:
  On May 3, 2009, at 7:42 AM, Wichert Akkerman wrote:
  
  And it's not limited to GAE; interactive traceback hasn't work for me
  for a month or so.
  
  It hasn't? What is happening instead?
 
 I click on the + and get a javascript error.

I noticed something interesting today: interactive traceback does not
work with Firefox 3.5b4, but works fine with Safari 4 beta.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: using buildout with pylons

2009-05-19 Thread Wichert Akkerman

Previously Chris Withers wrote:
 
 Hi All,
 
 I found this:
 
 http://wiki.pylonshq.com/display/pylonscommunity/Howto+install+Pylons+with+buildout
 
 ...which looks nice and straight forward. However, I've been having some 
 problems. If I do *exactly* what's on that page, it works, so I guess I 
 must have an issue at my end.
 
 BUT, one thing I have noticed so far is that after running buildout, I 
 end up with eggs for Paste, PasteDeploy and PasteScript in 
 pylons_buildout/myproject, which is wrong.

Everything in setup_requires and test_requires is installed there, and
buildout can't prevent that. As a workaround you can move those
dependencies to install_requires.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: using buildout with pylons

2009-05-19 Thread Wichert Akkerman

Previously Chris Withers wrote:
 
 Wichert Akkerman wrote:
  BUT, one thing I have noticed so far is that after running buildout, I 
  end up with eggs for Paste, PasteDeploy and PasteScript in 
  pylons_buildout/myproject, which is wrong.
  
  Everything in setup_requires and test_requires is installed there, 
 
 Why?
 
  and
  buildout can't prevent that. 
 
 Again, why?

setuptools internals do that, and buildout has no influence over that as
far as I know. If you want to discuss that distutils-sig is the right
list.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: deploying to production?

2009-05-20 Thread Wichert Akkerman

Previously Chris Withers wrote:
 * I'd like to be using buildout for things wherever possible, the 
 following is what I have so far:
 
 [buildout]
 parts = pylons
 develop = myproj
 
 [pylons]
 recipe = zc.recipe.egg
 eggs =
Pylons
PasteScript
myproj

myproj should depend on Pylons and PasteScript, so don't list them here.
You will need to use dependent-scripts = true to get bin/paster
generated.

If you want to deploy using mod_wsgi you can use the
collective.recipe.modwsgi buildout recipe.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Logging example in Windows (lama)

2009-05-27 Thread Wichert Akkerman

Previously durumdara wrote:
 Can I get some callback that starts at/before every requests where I
 can log everything what I need?

Write a tiny bit of WSGI middleware?

Wichert.

-- 
Wichert Akkerman wich...@wiggy.netIt is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Authkit vs repoze.who for openid

2009-07-19 Thread Wichert Akkerman

On 7/19/09 8:57 PM, Dalius Dobravolskas wrote:
 Damjan wrote:
 2) Your server should remember somehow who and when initiated OpenID
 request. So it create OpenID session and saves it to database (OpenID
 session usually is encoded into return URL);

 I can remember that in the http session (which could be Beakers secure
 cookie)

 I guess that's not the most secure thing to do but if you want you could
 try to write your own OpenID implementation. It might be possible that I
 have oversimplified everything and there are more steps to make OpenID
 secure. I really doubt that OpenID authors were that stupid so they have
 not thought about secure cookies ;-)

It's a prefectly valid thing to do, and I do not see why you should not 
do that. The standard python openid implementation encourages this type 
of approach by making the store pluggable.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.net   It is simple to make things.
http://www.wiggy.net/  It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Authkit vs repoze.who for openid

2009-07-19 Thread Wichert Akkerman

On 7/19/09 10:08 PM, Damjan wrote:
 I guess that's not the most secure thing to do but if you want you could
 try to write your own OpenID implementation. It might be possible that I
 have oversimplified everything and there are more steps to make OpenID
 secure. I really doubt that OpenID authors were that stupid so they have
 not thought about secure cookies ;-)
 It's a prefectly valid thing to do, and I do not see why you should not
 do that. The standard python openid implementation encourages this type
 of approach by making the store pluggable.

 what's the The standard python openid implementation ?

http://openidenabled.com/python-openid/

Wichert.


-- 
Wichert Akkerman wich...@wiggy.net   It is simple to make things.
http://www.wiggy.net/  It is hard to make things simple.

--~--~-~--~~~---~--~~
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: Launching a background process

2009-07-27 Thread Wichert Akkerman

On 7/27/09 8:40 AM, Graham Dumpleton wrote:


 On Jul 27, 2:07 pm, Dave Forgactylerd...@gmail.com  wrote:
 I am trying to write an application that will allow a user to launch a
 fairly long-running process (5-30 seconds). It should then allow the
 user to check the output of the process as it is generated.  The
 output will only be needed for the user's current session so nothing
 needs to be stored long-term.  I have two questions regarding how to
 accomplish this:

 1. What is the best way to launch a background process such as this
 with a Pylons controller?

 2. What is the best way to get the output of the background process
 back to the user?

 Often the better way of doing this is to run a separate persistent
 long running process which has an XML-RPC interface and have the web
 application communicate with the back end process using XML-RPC. This
 avoids all the mess that can often occur with forking off a web
 application process.

zc.async (see http://packages.python.org/zc.async/1.5.0/ ) might also be 
interesting.

Wichert.

--~--~-~--~~~---~--~~
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: Enabling logging for collective.recipe.modwsgi

2009-08-07 Thread Wichert Akkerman

Hi Phil,

On 8/7/09 10:31 , Kershaw, PJ (Philip) wrote:
 Hi Wichert,
 I've been making use of your modwsgi buildout recipe for sometime now -
 thanks :) ... but have been wondering about the best way to integrate
 logging capability into the WSGI script that's generated. Looking at:
 http://groups.google.com/group/pylons-discuss/browse_thread/thread/9b9add4529b3779c?pli=1
 I can do something like this to enable the logging configuration to be
 picked up from my ini file:

 from paste.deploy import loadapp
 from paste.script.util.logging_config import fileConfig
 configFilePath = /usr/local/myapp/etc/myapp.ini
 fileConfig(configFilePath)
 application = loadapp(config:+configFilePath)
 In your buildout recipe code I could override the default
 WRAPPER_TEMPLATE or is there a way I could do it via an option in my
 buildout config?

I could not see a reason not to do this by default, so I changed the 
template wrapper in collective.recipe.modwsgi and released a new version 
1.2 with this change. Thanks for the feedback!

Wichert.

--~--~-~--~~~---~--~~
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: pylons with chameleon?

2009-09-19 Thread Wichert Akkerman

On 2009-9-16 21:06, Iain Duncan wrote:

 Hi folks, I have not built enough pylons to be know how to switch
 templating languages beyond mako and genshi, but I'm interested in using
 Chameleon. Has anyone got any examples up of what one needs to do to use
 Chameleon?

In config/environment.py:

from genshi.template import TemplateLoader as GenshiTemplateLoader

def load_environment(global_conf, app_conf):
 ...
 ...

 # Create the chameleon TemplateLoader
 config['pylons.app_globals'].pt_loader = TemplateLoader(
 paths['templates'], auto_reload=True)

Add a new file in lib (mine is called lib/pt.py):

from pylons.templating import pylons_globals
from pylons.templating import cached_template


def render_pt(template_name, cache_key=None, cache_type=None,
   cache_expire=None):
 Render a page template with z3c.pt.

 def render_template():
 globs = pylons_globals()
 template = globs[app_globals].pt_loader.load(template_name)
 return template(**globs)

 return cached_template(template_name, render_template, 
cache_key=cache_key,
 cache_type=cache_type, cache_expire=cache_expire)


def render_text(template_name, cache_key=None, cache_type=None,
   cache_expire=None):
 Render a text template with z3c.pt.

 def render_template():
 globs = pylons_globals()
 template = globs[app_globals].pt_loader.load(template_name, 
format=text)
 return template(**globs)

 return cached_template(template_name, render_template, 
cache_key=cache_key,
 cache_type=cache_type, cache_expire=cache_expire)


you can then use render_pt to render html/xml templates, and render_text 
to render text templates, exactly like you use other templating languages.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.net   It is simple to make things.
http://www.wiggy.net/  It is hard to make things simple.

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



  1   2   >