Using Mako 2

2007-05-15 Thread voltron

Hi all

I asked a question a while back about using Mako templates, in the
thread, it was suggested that one should leave these lines out
completely:

# The following template options are passed to your template engines
#tmpl_options = {}
#tmpl_options['myghty.log_errors'] = True
#tmpl_options['myghty.escapes'] = dict(l=webhelpers.auto_link,
s=webhelpers.simple_format)

this kills the Paste serve outright, the only thing that works is to
define an empty dict

tmpl_options = {}

Maybe the docs should reflect this?


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



Paster server in production

2007-05-15 Thread voltron

Hi all

I have taken the advice from this forum and have installed nginx as a
proxy to the paster server. this works well, but I´m really, really
worried about using the Paster server in a production site, for
example, when testing a Mako template, the server just died. Are there
tips out there to ensure stability? Or at least to make sure that all
types of errors are handled gracefully?

Thanks


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



Re: Paster server in production

2007-05-15 Thread Christoph Haas

On Tue, May 15, 2007 at 12:56:53AM -0700, voltron wrote:
 I have taken the advice from this forum and have installed nginx as a
 proxy to the paster server. this works well, but I´m really, really
 worried about using the Paster server in a production site, for
 example, when testing a Mako template, the server just died. Are there
 tips out there to ensure stability? Or at least to make sure that all
 types of errors are handled gracefully?

I can't comment on how to make Paste handle internal error less evily but
http://docs.pythonweb.org/display/pylonscookbook/Pylons+deployment+with+daemontools
explains how to at least restart the daemon if it dies.

 Christoph


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



Bug with beaker.cache ?

2007-05-15 Thread Alexandre CONRAD

Hello,

I'm trying to setup some caching with beaker.cache for my expensive 
users/groups/privileges database retrieval process. But there seem to be 
a bug when testing the keys in the cache:

# Setup a users container and set (key, value) pair
  cache.get_cache(users).set_value(anonymous, model.User())

# Test using use the has_key method
  cache.get_cache(users).has_key(anonymous)
False
  cache.get_cache(users).has_key(foo)
0

# and try with in
  anonymous in cache.get_cache(users)
False
  foo in cache.get_cache(users)
False

# And now try to retrieve the data.
  cache.get_cache(users).get_value(anonymous)
mp.models.users.User object at 0x13f2e50

# So I use the try/except hack to work it around
  try:
... cache.get_cache(users).get_value(foo)
... except KeyError, e:
... Key not found: %s % e
...
Key not found: 'foo'

Trying to look at the source code, it seems it goes down to the 
container object (in this case DBMContainer), which is in the package 
MyghtyUtils, which is a single, unreadable, .egg file here.

Using:
- Beaker-0.6.3-py2.4.egg
- MyghtyUtils-0.52-py2.4.egg

Regards,
-- 
Alexandre CONRAD


--~--~-~--~~~---~--~~
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: Installing pylons on Debian Sarge

2007-05-15 Thread Mike Orr

 And what formerly has been known as
 apt-get (for most people the main reason to use Debian) is now
 aptitude.

Thanks, I hadn't heard of aptitude.  I recently switched to Kubuntu
after abandoning Debian a few years ago, and still use apt-get along
with adept_manager (KDE's front end).  [Running 'aptitude' ...]  It
seems to be an update of the old dselect program (a console-based
visual package chooser) plus the apt-get commands.

 Search docs.pythonweb.org for sandbox. There are different approaches
 for installing packages on Debian. Debian developers will always tell
 you to use Debian's shipped packages. While other people may argue that
 setuptools+cheeseshop+eggs are the real way to install software. The
 problem with the latter approach is that Debian doesn't know about
 software you installed manually. So if you apt-get install pylons and
 have other packages lying around on your system you will get into bad
 trouble sooner or later because it depends on the search path which
 version you use.

Using OS packages is generally better for a quiet life if the package
is stable and you don't need the just-released-yesterday version.
It's also a good fallback if you have trouble easy_install'ing a
Python package that depends on external C libraries or headers.
However, it doesn't work if the package or its dependencies are
evolving rapidly and you need to use a feature or bugfix that's only
in the development or just-released version -- which I frequently
encounter with Pylons.

I use OS packages for things that can be hard to compile
(python-mysql, Imaging) or that I only use occasionally (docutils),
and make a workingenv [1] for each Pylons app (separate from the
application directory itself), and easy_install Pylons and
application-specific packages into it.

[1] http://cheeseshop.python.org/pypi/workingenv.py/

Installing the same package at the OS level and easy_install'ing it
could lead to version skew, since Python sometimes adds eggs to
sys.path in a different order than you'd like.

-- 
Mike Orr [EMAIL PROTECTED]

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



Re: Bug with beaker.cache ?

2007-05-15 Thread Michael Bayer


has_key passes unit tests added in rev 70, using DBM files like your  
example, im fairly certain this worked in older versions so you might  
want to double check your cache expiry/etc. and/or upgrade to beaker  
trunk; fixed/added support for unicode keys in rev 71.



--~--~-~--~~~---~--~~
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: Suggested standard way to import modules

2007-05-15 Thread Mike Orr

On 5/10/07, Ben Bangert [EMAIL PROTECTED] wrote:

 Spider wrote:
  Python guru Fredrik Lundh has an article at 
  http://effbot.org/zone/import-confusion.htm
  in which he discusses use of the import statement. He says,
  essentially :
 import X should be the normal method of importing
 from X import * is bad practice
 from X import Y is sometime ok
  That seems to be the general agreement in the python world.
 
 This decision was explicitly made, and I have no intention of changing
 it in the Pylons defaults in the future. The main reason for this is for
 both DRY and for ease of use. You need several things in all your
 controllers, why should you import them over and over again in every
 single controller?

Hear, hear.  lib.base is really a special case because if you copy all
those dozen import lines into every controller, you'll have to change
all of them if something moves or you add something.  Better to
consider them a common denominator of symbols available in every
controller.

The main problem comes with packages that export dozens of symbols
like SQLAlchemy.  I tried import sqlalchemy as sa and ultimately
went to importing each symbol as  I need it.

-- 
Mike Orr [EMAIL PROTECTED]

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



How to flush stale cache in Myghty? Beaker?

2007-05-15 Thread Chris Shenton

My app shows an overview of items, and lets me drill down into the
details for a single item; pretty common.  These item instances get
their data from a (RDF) database and renders with Myghty.  Fine so far.

But if I delete one of these individual items, then return to the
overview or specific details page, I still see the populated pages.
If I try to to do something with these items, my app tells me that the
actual data instance in the DB is in fact gone.

So I think Myghty is caching the items and I need to flush (or clear
or expire) the cache.  But I'm not finding how to do this in docs or
google searches.

I've got another method which my colleague uses to get the overview of
items, and it's decorated with a beaker_cache so I'm assuming I need
to flush this one too -- but don't know how:

@beaker_cache(expire=6000, type=memory)
@restrict(GET, HEAD)
def get_class_collection(self, class_id, content_type): 
...

So after deleting my item instance, I would want to flush the cache
for the item's display page and the items (class) overview page. 

Any pointers? Thanks.


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



Re: Paster server in production

2007-05-15 Thread Ian Bicking

voltron wrote:
 I have taken the advice from this forum and have installed nginx as a
 proxy to the paster server. this works well, but I´m really, really
 worried about using the Paster server in a production site, for
 example, when testing a Mako template, the server just died. Are there
 tips out there to ensure stability? Or at least to make sure that all
 types of errors are handled gracefully?

It's unlikely that the paster server is what's causing the failure. 
Generally a segfault comes from some C code.  In-process there's no real 
way to handle it -- the only way is to have another process watching and 
restarting as necessary.  If segfaults happen a lot, there's something 
distinctly wrong with your installation.

You might find paster serve --monitor helpful; it does this process 
monitoring.  Make sure you use the latest Paste Script if you use that 
option.  daemontools or monit or something like that can also do the 
same kind of thing.

   Ian

--~--~-~--~~~---~--~~
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: Paster server in production

2007-05-15 Thread Ian Bicking

Cliff Wells wrote:
 On Tue, 2007-05-15 at 17:34 +, __wyatt wrote:
 On May 15, 12:56 am, voltron [EMAIL PROTECTED] wrote:
 Hi all

 I have taken the advice from this forum and have installed nginx as a
 proxy to the paster server. this works well, but I´m really, really
 worried about using the Paster server in a production site, for
 example, when testing a Mako template, the server just died. Are there
 tips out there to ensure stability? Or at least to make sure that all
 types of errors are handled gracefully?
 I'm not sure this is a Paster issue. I think any back end server will
 crash on an unhandled exception.
 
 You could wrap all your render_response calls in a try/except (via a
 custom render_response method, say) and email any unexpected errors to
 yourself. Or something of that nature...
 
 Hm, this is what mine does already (exceptions don't crash Paster, but I
 do get an email containing the exception).  Perhaps this segment from
 my .ini file does it?
 
 [DEFAULT]
 debug = false
 email_to = [EMAIL PROTECTED]
 smtp_server = localhost
 error_email_from = [EMAIL PROTECTED]

Yes, but exceptions *definitely* don't ever kill paster.  Only a 
segfault does, because segfaults kill everything.

   Ian



--~--~-~--~~~---~--~~
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: Paster server in production

2007-05-15 Thread Cliff Wells

On Tue, 2007-05-15 at 17:34 +, __wyatt wrote:
 On May 15, 12:56 am, voltron [EMAIL PROTECTED] wrote:
  Hi all
 
  I have taken the advice from this forum and have installed nginx as a
  proxy to the paster server. this works well, but I´m really, really
  worried about using the Paster server in a production site, for
  example, when testing a Mako template, the server just died. Are there
  tips out there to ensure stability? Or at least to make sure that all
  types of errors are handled gracefully?
 
 I'm not sure this is a Paster issue. I think any back end server will
 crash on an unhandled exception.

 You could wrap all your render_response calls in a try/except (via a
 custom render_response method, say) and email any unexpected errors to
 yourself. Or something of that nature...

Hm, this is what mine does already (exceptions don't crash Paster, but I
do get an email containing the exception).  Perhaps this segment from
my .ini file does it?

[DEFAULT]
debug = false
email_to = [EMAIL PROTECTED]
smtp_server = localhost
error_email_from = [EMAIL PROTECTED]

I haven't looked at the source, but possibly setting these values
enables exception handling in Paster that isn't on by default.


Also, since you're using Nginx, I *highly* recommend setting up multiple
backends as outlined here:

http://blog.twisty-industries.com/users/cliff/load-balancing-for-turbogears-using-nginx

These instructions are easily applicable to Pylons/Paste as well as
TurboGears.


Cliff



--~--~-~--~~~---~--~~
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: RDF backed Pylons

2007-05-15 Thread Philip Cooper

On 5/14/07, Chris K Wensel [EMAIL PROTECTED] wrote:

 the website left me a little confused.

Yeah, I should do some more posting there.

 will it let me round-trip
 modifications to the backing store? or are there limitations on what can be
 written back?

It will round trip but this is immature.  Expecting an rdflib.Literal
to be passed in is not a good idea long term (backend specific).  Also
saving Lists and Collections is something I'm nor sure about how to
do.


   But Sparta looks great.
 
  Don't know much about critical mass on open sourcing stuff.  Which
  Sparta features are attractive? I may have them in my development
  code already.  For me the lack of caching in Sparta made it a dead
  end.
 

 yeah, can't say if it's useful, but it looked stable enough.

 I'm not sold on a OO mapping from/to RDF exactly.

I'm hoping that it will lower the bar for folks who just want to do
fill-in-the-blank and are not up to speed on RDF.

 but it would save some
 effort for simple things, but i would love to break out into RDF centric
 things if the OO model doesn't support me. but then again, it may be just
 sufficient..

As the code matures there are lots of benefits.
e.g. when saving: check for OWL restrictions (predicate range etc)

--
Phil

--~--~-~--~~~---~--~~
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: Paster server in production

2007-05-15 Thread voltron

Thanks guys for the tips. I have decided to monitor Nginx and the
Paster servers with Monit, its easy to setup and there is a deb
package for debian


--~--~-~--~~~---~--~~
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: Using Mako 2

2007-05-15 Thread voltron

Maybe I spoke too soon, on Ubuntu, it still just dies outright :-(



On May 15, 9:50 am, voltron [EMAIL PROTECTED] wrote:
 Hi all

 I asked a question a while back about using Mako templates, in the
 thread, it was suggested that one should leave these lines out
 completely:

 # The following template options are passed to your template engines
 #tmpl_options = {}
 #tmpl_options['myghty.log_errors'] = True
 #tmpl_options['myghty.escapes'] = dict(l=webhelpers.auto_link,
 s=webhelpers.simple_format)

 this kills the Paste serve outright, the only thing that works is to
 define an empty dict

 tmpl_options = {}

 Maybe the docs should reflect this?


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



Error with myghty request processing unicode

2007-05-15 Thread Victor Kryukov

Hi group,

I've just installed pylons yesterday, so I apologize if the question
I'm asking is too trivial.

Here it is: I tried to redefine TemplateController as suggested in
it's documentation string:

from ljeye.lib.base import *
import myghty.exception

class TemplateController(BaseController):
def view(self, url):
try:
return render_response('/'+url)
except myghty.exception.ComponentNotFound:
return Response(code=404)

I also placed file called 'help.myt' under /templates.

Now, when I'm trying to access localhost:5000/help.myt, I'm getting
the following error:

Error(AttributeError): 'unicode' object has no attribute
'is_file_component'

The reason for this error lies in the way Myghty handles unicode
components:

Error:
Error(AttributeError): 'unicode' object has no attribute
'is_file_component'
File:
/usr/lib/python2.5/site-packages/Myghty-1.1-py2.5.egg/myghty/
request.py line 227
Context:
224: try:
225: if type(component) == types.StringType:
226: component =
self.fetch_lead_component(component)
227: elif component.is_file_component():
228: self.request_path = component.path
229:
230: self.request_component = component

For some reason, component in my case is u'help.myt', and hence the
type(component)==types.StringType comparison failes.

Note that I'm using freshly downloaded 0.9.5 Pylons, python2.5 etc.,
and I'm just playing with freshly created pylons project.

I would appreciate if you could clarify that for me.

Best Regards,
Victor.


--~--~-~--~~~---~--~~
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: [RFC] Alternative paginator

2007-05-15 Thread Christoph Haas

On Tue, May 15, 2007 at 03:27:39PM -0700, Mike Orr wrote:
 
 On 5/5/07, Christoph Haas [EMAIL PROTECTED] wrote:
  as some of you already know I have never been very happy with
  Webhelpers' built-in pagination module. So I wrote my own (that is NOT
  compatible with the existing one) and I love it so far.
 
  Interested? Get it from http://workaround.org/pylons/paginator/ and let
  me know what you think. Some of the features:
 
 Excellent, I'll have a use for it this week.  I suppose it can work
 with a SQLAlchemy Select as well as Table or an ORM query?

Thanks to Ben's orm module it can. See the rest docs that accompany the
module. I just lack a good example in SQLObject.

Cheers
 Christoph


--~--~-~--~~~---~--~~
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: RDF backed Pylons

2007-05-15 Thread Kendall Clark

On May 15, 2007, at 4:58 PM, Philip Cooper wrote:


 On 5/14/07, Chris K Wensel [EMAIL PROTECTED] wrote:

 the website left me a little confused.

 Yeah, I should do some more posting there.

 will it let me round-trip
 modifications to the backing store? or are there limitations on  
 what can be
 written back?

 It will round trip but this is immature.  Expecting an rdflib.Literal
 to be passed in is not a good idea long term (backend specific).

Until v. recently, the way you got typed literals was painful. They  
may have improved this recently, though.

But it's not *that* rdflib-specific, really. No more so than Python  
db-api drivers returning datetime objects in result sets, really.

If there is a Python RDF API, it's rdflib (for good and bad IMO).

   Also
 saving Lists and Collections is something I'm nor sure about how to
 do.

Friends don't let friends use RDF collections or lists or bags, etc.  
Seriously, I just wouldn't do anything with these. They really aren't  
best practice and not that commonly used.

But now we're really off-topic re: Pylons. :

Cheers,
Kendall


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