Re: Permissions in template tags

2008-10-23 Thread dougeven

Something like this should work...

from django import template
import datetime
class CurrentTimeNode(template.Node):
def __init__(self, format_string):
self.format_string = format_string
def render(self, context):
# apply appropriate permissions for this tag
user = context['user']
if user.has_perm('your_package.your_permission_codename'):
return
datetime.datetime.now().strftime(self.format_string)
else:
return 'You do not have permission to see what time it
is.'


On Oct 21, 4:44 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Simple question: is it possible to access all user permissions in
> template tags just as in regular templates through the {{ perms }}
> context variable or do I need to manually pass the permissions are
> template tag params? By default the perms map does not seem to work in
> tags.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Trouble setting up Django and Apache

2007-03-22 Thread dougeven

I don't know if it's an encouraged practice, but I established a
symbolic link to my app folder in site-packages which ensures that the
app is in the python path. Until I did that I received the same error
from apache as you have.

On Mar 22, 10:49 pm, "benrawk" <[EMAIL PROTECTED]> wrote:
> Also, when I import and print sys.path into a python session, with
> apache running in the background, sys.path does not include '/home/
> benrawk'. Is it supposed to? Is there a way I can check the value of
> PythonPath as it is defined in httpd.conf?
>
> On Mar 22, 8:37 pm, "benrawk" <[EMAIL PROTECTED]> wrote:
>
> > Hello, thank your for your reply. Tried everything, getting positive
> > results, but still can't loadhttp://localhost/mysite/.
>
> > 1) permissions on both /home, /home/benrawk, and /home/benrawk/mysite
> > are 'drwxr-xr-x'
>
> > 2) I succesfully imported mysite.settings after adding /home/benrawk
> > to the sys.path.
>
> > 3) mysite/ has __init__.py in it.
>
> > Any other ideas? Would really like to get this to work...any help is
> > greatly appreciated.
>
> > On Mar 22, 1:02 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
> > wrote:
>
> > > On Thu, 2007-03-22 at 07:57 +,benrawkwrote:
> > > > Hello,
>
> > > > Recieving a common error, but have trolled the message boards, and
> > > > have not found a solution. My httpd.conf file contains the following
> > > > relevant snippet:
>
> > > > 
> > > > SetHandler python-program
> > > > PythonPath "['/home/benrawk'] + sys.path"
> > > > SetEnv DJANGO_SETTINGS_MODULE mysite.settings
> > > > PythonHandler django.core.handlers.modpython
> > > > PythonDebug On
> > > > Allow from localhost
> > > > 
>
> > > > The path of my project file with settings.py in it is /home/benrawk/
> > > > mysite.
>
> > > Is /home/benrawkreadable by the user running Apache (typically,
> > > "apache")? Similarly is mysite/ readable by that user?
>
> > > Does your settings.py file have syntax errors in it? If you start a
> > > python prompt, import sys and add /home/benrawkto the front of
> > > sys.path, can you import mysite.settings without error?
>
> > > Does mysite/ have an __init__.py file in it? Actually, this is a
> > > redundant question if you passed the previous test, but it might explain
> > > why the import failed if you can't even import it from the command line.
>
> > > Those are the likely causes of problems: apache can't read the files in
> > > question, or settings.py has syntax errors.
>
> > > Regards,
> > > Malcolm


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



Re: Problem with use of an apostrophe in query

2007-03-22 Thread dougeven

Just a follow-up on this issue...

It turns out that the problem was that the data being queried against
contained a close-single-quote character instead of an apostrophe. A
query for "Al's Hobby Shop" was not matching because there was no
apostrophe in the data. Replacing the close-single-quote character
with an apostrophe in the database solved the problem.

On Mar 13, 10:39 pm, "dougeven" <[EMAIL PROTECTED]> wrote:
> The production system is Apache2.0/mod_python, the development system
> is django runserver...
>
> On Mar 13, 10:21 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
>
> > On 14-Mar-07, at 8:32 AM, dougeven wrote:
>
> > > The development environment is Ubuntu Dapper, and the production
> > > system runs a recent Mandriva release.
>
> > are both on the same type of platform - that is, both on apache/
> > mod_python, or is one on the django runserver and the other not?
>
> > --
>
> > regards
> > kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/web/


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



Re: Problem with use of an apostrophe in query

2007-03-13 Thread dougeven

The production system is Apache2.0/mod_python, the development system
is django runserver...

On Mar 13, 10:21 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 14-Mar-07, at 8:32 AM, dougeven wrote:
>
> > The development environment is Ubuntu Dapper, and the production
> > system runs a recent Mandriva release.
>
> are both on the same type of platform - that is, both on apache/
> mod_python, or is one on the django runserver and the other not?
>
> --
>
> regards
> kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/web/


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



Problem with use of an apostrophe in query

2007-03-13 Thread dougeven

I've recently deployed my first Django app and I'm grateful to all the
Django developers for such a solid framework. It has been a
surprisingly pleasant experience. I have one nagging issue, however.
In the production environment queries using "icontains" where the
value contains an apostrophe (as in "Al's Hobby Shop") return no
results, even though they should. The same query code returns the
expected result in my development environment. Obviously something's
different.

The development environment is Ubuntu Dapper, and the production
system runs a recent Mandriva release. Both use the same recent
checkout of Django from trunk, and PostgreSQL 8.1.8. My suspicion is
that the problem is with psycopg. I've shied away from psycopg2 -
should I have?

Does anyone have experience with this issue? Any advice as to where to
concentrate troubleshooting efforts?


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



Re: Django snippets

2007-02-26 Thread dougeven

> Do you mean it throws a validation error? Or that the field is too
> small for you to see the whole address as you type?

The email field will not accept an address more than 30 characters.
The one I want to use is 31! I didn't notice until after submitting
the form that the final "m" in com was missing and so, of course,
never received the activation email. And now can't re-apply until the
username I wanted expires in a couple of days?...

Anyway, I'm looking forward to using this site - thanks for making it.

On Feb 26, 11:25 am, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On 2/26/07, akaihola <[EMAIL PROTECTED]> wrote:
>
> > One small note:
> > The e-mail field when registering towww.djangosnippets.orgis too
> > short for the e-mail address I use for on-line services.
>
> Do you mean it throws a validation error? Or that the field is too
> small for you to see the whole address as you type?
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."


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