Re: Django ORM and Google Gears (or alternatives?)

2009-08-23 Thread Russell Keith-Magee

On Sun, Aug 23, 2009 at 11:23 AM, Victor Hooi wrote:
>
> heya,
>
> I've got a small project involving an ordering system web application.
> One of the requirements is offline functionality (i.e. it will
> function without a direct internet connection, at least on a limited
> scale - e.g. they can search their previous orders, and submit orders,
> with a cached pricelist, maybe even generate printable output, either
> print-suitable HTML or PDFs etc.).
>
> Now, I know there was the django-offline project (http://
> code.google.com/p/django-offline/). And there was even a question on
> django-users asing about what happened ot the project (http://
> osdir.com/ml/DjangoUsers/2009-06/msg01790.html).
>
> Are there any similar efforts out there to integrate Google Gears into
> Django? Or anybody posting about doing something similar? The Rails
> guys have gearsonrails (http://code.google.com/p/gearsonrails/),
> however, I do find I'm just more comfortable in Django/Python.
>
> I suppose my question is, is Django really a good fit for what I'm
> doing? Primarily, I'm using it for the ORM layer, I guess, so if using
> Gears means I can't use the ORM...hmm...suggestions?

There isn't any official effort underway to integrate Gears into
Django. I'm not aware of any external projects either, but I haven't
really been on the lookout for them.

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: TypeError: execute() takes at most 3 arguments (4 given)

2009-08-23 Thread Daniel Roseman

On Aug 22, 9:14 pm, kevin  wrote:
> cursor.execute("SELECT a,b,c FROM Table_Name WHERE a = %s AND b = %s ",
> [string1],[string2])
>
> gives me the following error:
>
> TypeError: execute() takes at most 3 arguments (4 given)
>
> Where did i go wrong?

You have got string1 and string2 in separate lists. Should be:
cursor.execute("SELECT a,b,c FROM Table_Name WHERE a = %s AND b = %s
",
[string1, string2])
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Reusable/plugable apps integrations best practices

2009-08-23 Thread Andrea Zilio

I'm intrested in the answer too

On Aug 23, 1:36 am, "Chris H."  wrote:
> So I'm trying to get my head around making my small, tightly focused
> apps reusable.  I've done this, but right now still have
> "dependencies" between one another, that I'd like to remove.  For
> simplicity sake, I have an Articles, Events, and Photos app.
>
> Right now each Article has a photos.photo and events.event foreign key
> relationship and each event has a photos.photo_set fk relationship.
> Thus, as currently written all three apps are required.  I'd like to
> rework this such that the installation of each application is not
> required, and I'd think that additional functionality should live in
> the newer app.
>
> That is, when Photos gets "installed" it looks for Articles, if that
> is installed it hooks into the Photos model to supply the photo
> relationship.  And if Events is installed, it'll provide the photoset
> relationship.  If neither is installed, that's okay too, it just
> provides it's base functionality.  When Events gets installed, it
> looks for Articles, and if so allows you to relate an article to an
> event.
>
> Surely, this has done before, right?  Or am I approaching it wrong?
> My google foo fails me...what do I need to be searching for??
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Permissions issue with image uploads

2009-08-23 Thread Anogar

I'm trying to implement a simple image upload inside my blog, and I
had it working on my local machine, but when I deployed it threw this
error:

OSError at /path/
(13, 'Permission denied')


So, it's clearly a permissions issue - but I can't quite figure out
how to fix it. Just to confirm my idea I chmod'd the permissions to
777 - and the whole thing suddenly works perfectly, but that's
obviously not a permanent solution.

I tried chown'ing the file over to www-data which is my Apache
process, but that didn't work either. Who should own my uploads
folder?

Thanks!

-Ryan

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Permissions issue with image uploads

2009-08-23 Thread Ramdas S
chowning www-data will work. Make sure the directory has chown -R and chmod
-R,

suppose you are uploading to media/images

chown -R www-data media/images
chmod -R 777 media/images


On Sun, Aug 23, 2009 at 11:17 AM, Anogar  wrote:

>
> I'm trying to implement a simple image upload inside my blog, and I
> had it working on my local machine, but when I deployed it threw this
> error:
>
> OSError at /path/
> (13, 'Permission denied')
> 
>
> So, it's clearly a permissions issue - but I can't quite figure out
> how to fix it. Just to confirm my idea I chmod'd the permissions to
> 777 - and the whole thing suddenly works perfectly, but that's
> obviously not a permanent solution.
>
> I tried chown'ing the file over to www-data which is my Apache
> process, but that didn't work either. Who should own my uploads
> folder?
>
> Thanks!
>
> -Ryan
>
> >
>


-- 
Ramdas S
+91 9342 583 065

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: TypeError: execute() takes at most 3 arguments (4 given)

2009-08-23 Thread Bryan

Daniel is right on.  And for future reference, it says "3 arguments"
which may seem misleading, but keep in mind that the cursor object
itself is the first argument.

On Aug 22, 4:14 pm, kevin  wrote:
> cursor.execute("SELECT a,b,c FROM Table_Name WHERE a = %s AND b = %s ",
> [string1],[string2])
>
> gives me the following error:
>
> TypeError: execute() takes at most 3 arguments (4 given)
>
> Where did i go wrong?

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Dates with varying specificity?

2009-08-23 Thread Doug Blank
On Sat, Aug 22, 2009 at 12:24 PM, ringemup  wrote:

>
> Has anyone here ever written an application that needed to be able to
> take a date field where the month or day was sometimes but not always
> known?  How would you handle this?  Using separate day/month/year
> fields instead of a DateField seems to sacrifice a lot of convenience
> and usability.
>

We've just begun to develop a web front-end to an open source genealogy
program (http://gramps-project.org) and are looking into this issue. We have
a sophisticated date object that includes different calendars (Julian,
Gregorian, etc) and date specifiers ("about 1863", "between Jan 1, 1734 and
Feb 1735") and more. We'll probably develop our own Model so that we can
treat these with some of the same convenience as DateField, but handle the
complexity from behind.

We don't have any of the date model coded yet, so this is just an FYI.

-Doug


>
> Thanks!
> >
>

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Image Location

2009-08-23 Thread When ideas fail

Hello, i'm having a problem getting images to display so I was
wondering if someone would be kind enough to help?

I have my settings.py set up as follows (content is the folder where
my static images are stored):

MEDIA_ROOT = '/home/mysite/content/'
MEDIA_URL = 'http://www.mysites.net/content/'

Then my template is like so:



where object.post_img = imgs/newMessage.jpg

but if i load the page up it doesn't appear. I checked the error log
it says:

File does not exist: /home/mysite/public_html/content, referer:
http://www.mysite.net

so it has added public_html to the path, how can i solve this issue?

Many Thanks

Andrew
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Image Location

2009-08-23 Thread Matthias Kestenholz

On Sun, Aug 23, 2009 at 3:54 PM, When ideas
fail wrote:
>
> Hello, i'm having a problem getting images to display so I was
> wondering if someone would be kind enough to help?
>
> I have my settings.py set up as follows (content is the folder where
> my static images are stored):
>
> MEDIA_ROOT = '/home/mysite/content/'
> MEDIA_URL = 'http://www.mysites.net/content/'
>
> Then my template is like so:
>
> 
>
> where object.post_img = imgs/newMessage.jpg
>
> but if i load the page up it doesn't appear. I checked the error log
> it says:
>
> File does not exist: /home/mysite/public_html/content, referer:
> http://www.mysite.net
>
> so it has added public_html to the path, how can i solve this issue?
>

By using the documented way to output the URL of a FileField / ImageField:



Look here for more information:
http://docs.djangoproject.com/en/dev/ref/models/fields/#filefield



Matthias

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Custom field types and newforms admin

2009-08-23 Thread Hanpan

Hi,

I have created a custom field type, which I am using like so:

image_thumb = ImageWithThumbsField(_('preview image'),
upload_to='uploads/projects')

But for some reason, when I run syncdb this custom field is being
completely ignored. I tried using the 'widget' argument, but that
caused an error. I also tried 'formfield_for_dbfield' in the admin.py,
but that didn't help at all.

Any suggestions?

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Complex query in model manager

2009-08-23 Thread CrabbyPete

or another words can I use a Q object in a model manager?

On Aug 23, 12:05 am, CrabbyPete  wrote:
> I have the following code in model manager
>
> class SpotMessageManager(models.Manager):
>
>       def for_user(self, user, start = 0, end = None, friends ):
>             messages = self.filter(user = user).order_by
> ('date_added').reverse()
>             ...
>
> friends is a list of users, and I want the query set to include the
> user and all the friends in the list. What is the best way to do this?
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Image Location

2009-08-23 Thread J. Cliff Dyer

On Sun, 2009-08-23 at 06:54 -0700, When ideas fail wrote:
> Hello, i'm having a problem getting images to display so I was
> wondering if someone would be kind enough to help?
> 
> I have my settings.py set up as follows (content is the folder where
> my static images are stored):
> 
> MEDIA_ROOT = '/home/mysite/content/'
> MEDIA_URL = 'http://www.mysites.net/content/'
> 
> Then my template is like so:
> 
> 
> 
> where object.post_img = imgs/newMessage.jpg
> 
> but if i load the page up it doesn't appear. I checked the error log
> it says:
> 
> File does not exist: /home/mysite/public_html/content, referer:
> http://www.mysite.net
 
1.  Check what's getting rendered in your HTML file for the src of that
img.

2. Make sure you're using a RequestContext, otherwise you won't have
MEDIA_URL available to your templates.

3. Figure out why public_html is showing up in the path reported by the
error log.

Some information that will help with debugging: 

 * Are you using apache, the dev server, or something else?
 * If the dev server, where does your URLConf point to for 
   static images?
 * What does the URLConf and view look like for the page that's
   getting rendered?

Cheers,
Cliff




--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Image Location

2009-08-23 Thread When ideas fail

I changed it to post_img.url but i assume thats a different way of
doing the same thing.

1.The html source gives the image location as "http://www.mysite.net/
content/imgs/newMessage.jpg"

2. I am using a RequestContext.

Its an apache server and these are the related directives:


 SetHandler None



 allow from all
 order allow,deny
 SetHandler None

Alias /imgs/ "/home/mysite/content/imgs/"

Andrew


On 23 Aug, 17:18, "J. Cliff Dyer"  wrote:
> On Sun, 2009-08-23 at 06:54 -0700, When ideas fail wrote:
> > Hello, i'm having a problem getting images to display so I was
> > wondering if someone would be kind enough to help?
>
> > I have my settings.py set up as follows (content is the folder where
> > my static images are stored):
>
> > MEDIA_ROOT = '/home/mysite/content/'
> > MEDIA_URL = 'http://www.mysites.net/content/'
>
> > Then my template is like so:
>
> > 
>
> > where object.post_img = imgs/newMessage.jpg
>
> > but if i load the page up it doesn't appear. I checked the error log
> > it says:
>
> > File does not exist: /home/mysite/public_html/content, referer:
> >http://www.mysite.net
>
> 1.  Check what's getting rendered in your HTML file for the src of that
> img.
>
> 2. Make sure you're using a RequestContext, otherwise you won't have
> MEDIA_URL available to your templates.
>
> 3. Figure out why public_html is showing up in the path reported by the
> error log.
>
> Some information that will help with debugging:
>
>  * Are you using apache, the dev server, or something else?
>  * If the dev server, where does your URLConf point to for
>    static images?
>  * What does the URLConf and view look like for the page that's
>    getting rendered?
>
> Cheers,
> Cliff
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Image Location

2009-08-23 Thread When ideas fail

I changed it to post_img.url but i assume thats a different way of
doing the same thing.

1.The html source gives the image location as "http://www.mysite.net/
content/imgs/newMessage.jpg"

2. I am using a RequestContext.

Its an apache server and these are the related directives:


 SetHandler None



 allow from all
 order allow,deny
 SetHandler None

Alias /imgs/ "/home/mysite/content/imgs/"

Andrew


On 23 Aug, 17:18, "J. Cliff Dyer"  wrote:
> On Sun, 2009-08-23 at 06:54 -0700, When ideas fail wrote:
> > Hello, i'm having a problem getting images to display so I was
> > wondering if someone would be kind enough to help?
>
> > I have my settings.py set up as follows (content is the folder where
> > my static images are stored):
>
> > MEDIA_ROOT = '/home/mysite/content/'
> > MEDIA_URL = 'http://www.mysites.net/content/'
>
> > Then my template is like so:
>
> > 
>
> > where object.post_img = imgs/newMessage.jpg
>
> > but if i load the page up it doesn't appear. I checked the error log
> > it says:
>
> > File does not exist: /home/mysite/public_html/content, referer:
> >http://www.mysite.net
>
> 1.  Check what's getting rendered in your HTML file for the src of that
> img.
>
> 2. Make sure you're using a RequestContext, otherwise you won't have
> MEDIA_URL available to your templates.
>
> 3. Figure out why public_html is showing up in the path reported by the
> error log.
>
> Some information that will help with debugging:
>
>  * Are you using apache, the dev server, or something else?
>  * If the dev server, where does your URLConf point to for
>    static images?
>  * What does the URLConf and view look like for the page that's
>    getting rendered?
>
> Cheers,
> Cliff
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Custom field types and newforms admin

2009-08-23 Thread Daniel Roseman

On Aug 23, 3:44 pm, Hanpan  wrote:
> Hi,
>
> I have created a custom field type, which I am using like so:
>
> image_thumb = ImageWithThumbsField(_('preview image'),
> upload_to='uploads/projects')
>
> But for some reason, when I run syncdb this custom field is being
> completely ignored. I tried using the 'widget' argument, but that
> caused an error. I also tried 'formfield_for_dbfield' in the admin.py,
> but that didn't help at all.
>
> Any suggestions?

You seem to be confusing model fields with form fields. Where are you
using this field, in a model or form definition? What are you
expecting syncdb to do, and what is it actually doing?
--
DR.

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Appeding entire table to a backup table

2009-08-23 Thread xocekim

Hello,

I have a MySQL table that gets cleared in the morning, populated
during the day, appended onto a backup table and the contents then
deleted.

The raw SQL is something along the lines of "INSERT INTO backup SELECT
* FROM today; DELETE FROM today;".

Is there a Django way of doing this? I would required something
similiar to this:
todays_records = Today.objects.all()
for record in todays_records:
Backup.objects.create(record)

I am aware I could simply do
for record in todays_records:
Backup.objects.create(value1=record.value1, value2=record.value2)

But I would think there is a better method I am not aware of?

Both Today table and Backup table have the exact same layout.

Any help would be appreciated

Mike

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Custom field types and newforms admin

2009-08-23 Thread Hanpan

Hi, thanks for the reply.

ImageWithThumbsField is custom field which extends ImageField. It
creates a thumbnail. I am using it in my model definition, nothing to
do with a form. syncdb is ignoring this field when it creates the
table completely.

On 23 Aug, 18:39, Daniel Roseman  wrote:
> On Aug 23, 3:44 pm, Hanpan  wrote:
>
> > Hi,
>
> > I have created a custom field type, which I am using like so:
>
> > image_thumb = ImageWithThumbsField(_('preview image'),
> > upload_to='uploads/projects')
>
> > But for some reason, when I run syncdb this custom field is being
> > completely ignored. I tried using the 'widget' argument, but that
> > caused an error. I also tried 'formfield_for_dbfield' in the admin.py,
> > but that didn't help at all.
>
> > Any suggestions?
>
> You seem to be confusing model fields with form fields. Where are you
> using this field, in a model or form definition? What are you
> expecting syncdb to do, and what is it actually doing?
> --
> DR.
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Test client following redirects despite follow=False?

2009-08-23 Thread Karen Tracey
On Thu, Aug 20, 2009 at 2:19 PM, ringemup  wrote:

>
> I'm running the test listed below, and the test client is submitting a
> request to /test2/ despite the follow=False parameter in
> self.client.get()  -- am I doing something stupid?
>
>def test_child_redirect(self):
>response = self.client.get('/test/', follow=False,
> HTTP_HOST=settings.TESTING_DOMAINS[0])
>self.assertRedirects(response, '/test2/',
> target_status_code=200)
>

I expect is it not the self.client.get that is following the redirect but
rather the assertRedirects.  assertRedirects checks that fetching the target
page returns target_status_code, and it needs to actually fetch the page to
check that.

Karen

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Custom field types and newforms admin

2009-08-23 Thread Hanpan

Hi, thanks for the reply.

ImageWithThumbsField is custom field which extends ImageField. It
creates a thumbnail. I am using it in my model definition, nothing to
do with a form. syncdb is ignoring this field when it creates the
table completely.

On 23 Aug, 18:39, Daniel Roseman  wrote:
> On Aug 23, 3:44 pm, Hanpan  wrote:
>
> > Hi,
>
> > I have created a custom field type, which I am using like so:
>
> > image_thumb = ImageWithThumbsField(_('preview image'),
> > upload_to='uploads/projects')
>
> > But for some reason, when I run syncdb this custom field is being
> > completely ignored. I tried using the 'widget' argument, but that
> > caused an error. I also tried 'formfield_for_dbfield' in the admin.py,
> > but that didn't help at all.
>
> > Any suggestions?
>
> You seem to be confusing model fields with form fields. Where are you
> using this field, in a model or form definition? What are you
> expecting syncdb to do, and what is it actually doing?
> --
> DR.
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Best practice on data security .. on record, table (model) db or url

2009-08-23 Thread Gerard

I did find a nice sidewide middleware login system which takes care of one 
aspect of my 'problem'. http://www.djangosnippets.org/snippets/1158/

Not completely to my taste, because it (me?) requires some css file in 
PUBLIC_URLS. Figured I'd start on the manual @login_required for now to get 
some handson experience first

I might *bump* this message again later.

Regards,

Gerard.

Sam Lai wrote:
> 2009/8/21 Gerard :
>> Hi All,
>>
>> I'm working on an invoice system, currently deployed the single user version
>>  in house. Next one is gonna be a full blown multi user setup. Having
>> fairly good knowledge of security, I was wondering what would be best
>> practice in Django for data separation. So user A only sees his customer
>> data and not the data from user B.
>>
>> Some side notes:
>> - Since there's a good auth system in Django I would like to take full
>> advantage of that.
>> - User session info will be used so al app users see the same url. Thus not
>> http://example.com/userid/customers but http://example.com/customers
>> - Fixating security on record level, seems error prone, coding wise
>> - Fixating on database seems badly manageble in the long run, since there
>> will be a lot of users, but not an incredible amount of data per user.
>>
> 
> Interesting stuff; I'm interested in knowing what the best practices are too.
> 
> One thing I'm considering doing is overriding the default manager in
> each model so that the current user is considered when making queries.
> This makes it harder for you to accidentally return all user's data in
> the view.
> 
> Of course, you can still have the default manager in the model; just
> name it something else so you have to consciously use it.
> 
> > 


-- 
self.url = www.gerardjp.com

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Appeding entire table to a backup table

2009-08-23 Thread Tim Chase

> The raw SQL is something along the lines of "INSERT INTO backup SELECT
> * FROM today; DELETE FROM today;".
> 
> Is there a Django way of doing this? I would required something
> similiar to this:
> todays_records = Today.objects.all()
> for record in todays_records:
> Backup.objects.create(record)

While you could do something like this Python/Django code, your 
raw SQL is far more efficient -- your transaction logs should 
have the two commands.  Depending on the quantity of data, the 
Python/Django way of doing this may have lots of INSERTs in your 
transaction logs.

Another possibility might be to have the .save() method save into 
both places ([today] and [backup]) so you can just DELETE FROM 
[today] and already have the content in [backup].

As an aside, the DELETE FROM is more portable, but in some 
environments TRUNCATE TABLE tblFoo is a more efficient way to 
clear out the contents (but may have auto-increment resetting 
side-effects).

So I'd just stick with your current solution and not try to use 
the Django ORM.

-tim



--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Image Location

2009-08-23 Thread When ideas fail

Seems to be working now.

Thanks.

On 23 Aug, 18:28, When ideas fail  wrote:
> I changed it to post_img.url but i assume thats a different way of
> doing the same thing.
>
> 1.The html source gives the image location as "http://www.mysite.net/
> content/imgs/newMessage.jpg"
>
> 2. I am using a RequestContext.
>
> Its an apache server and these are the related directives:
>
> 
>  SetHandler None
> 
>
> 
>  allow from all
>  order allow,deny
>  SetHandler None
>
> Alias /imgs/ "/home/mysite/content/imgs/"
>
> Andrew
>
> On 23 Aug, 17:18, "J. Cliff Dyer"  wrote:
>
> > On Sun, 2009-08-23 at 06:54 -0700, When ideas fail wrote:
> > > Hello, i'm having a problem getting images to display so I was
> > > wondering if someone would be kind enough to help?
>
> > > I have my settings.py set up as follows (content is the folder where
> > > my static images are stored):
>
> > > MEDIA_ROOT = '/home/mysite/content/'
> > > MEDIA_URL = 'http://www.mysites.net/content/'
>
> > > Then my template is like so:
>
> > > 
>
> > > where object.post_img = imgs/newMessage.jpg
>
> > > but if i load the page up it doesn't appear. I checked the error log
> > > it says:
>
> > > File does not exist: /home/mysite/public_html/content, referer:
> > >http://www.mysite.net
>
> > 1.  Check what's getting rendered in your HTML file for the src of that
> > img.
>
> > 2. Make sure you're using a RequestContext, otherwise you won't have
> > MEDIA_URL available to your templates.
>
> > 3. Figure out why public_html is showing up in the path reported by the
> > error log.
>
> > Some information that will help with debugging:
>
> >  * Are you using apache, the dev server, or something else?
> >  * If the dev server, where does your URLConf point to for
> >    static images?
> >  * What does the URLConf and view look like for the page that's
> >    getting rendered?
>
> > Cheers,
> > Cliff
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Reusable/plugable apps integrations best practices

2009-08-23 Thread Joshua Russo
You need to remove the references on one side or the other. You need to make
a choice. will events manage photos, or will photos manage events, and so
on. Then if events manage photos, you need to remove all references to
events from the photos app.
It sounds like it will take some reworking of your application logic, but
that's the nut of it.


On Sun, Aug 23, 2009 at 8:53 AM, Andrea Zilio  wrote:

>
> I'm intrested in the answer too
>
> On Aug 23, 1:36 am, "Chris H."  wrote:
> > So I'm trying to get my head around making my small, tightly focused
> > apps reusable.  I've done this, but right now still have
> > "dependencies" between one another, that I'd like to remove.  For
> > simplicity sake, I have an Articles, Events, and Photos app.
> >
> > Right now each Article has a photos.photo and events.event foreign key
> > relationship and each event has a photos.photo_set fk relationship.
> > Thus, as currently written all three apps are required.  I'd like to
> > rework this such that the installation of each application is not
> > required, and I'd think that additional functionality should live in
> > the newer app.
> >
> > That is, when Photos gets "installed" it looks for Articles, if that
> > is installed it hooks into the Photos model to supply the photo
> > relationship.  And if Events is installed, it'll provide the photoset
> > relationship.  If neither is installed, that's okay too, it just
> > provides it's base functionality.  When Events gets installed, it
> > looks for Articles, and if so allows you to relate an article to an
> > event.
> >
> > Surely, this has done before, right?  Or am I approaching it wrong?
> > My google foo fails me...what do I need to be searching for??
> >
>

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



multi-tenant website

2009-08-23 Thread Fernando

Is there a Django app that helps with handling multitenancy, that is,
having a single website and a single database serving multiple
organizations in a software-as-a-service fashion while avoiding one
tenant to interact with another's data?

I'm talking about the "Shared database, shared schema" scenario like
described in this article:

http://msdn.microsoft.com/en-us/library/aa479086(loband).aspx#mlttntda_topic2

"In this approach, all tenants share the same set of tables, and a
Tenant ID associates each tenant with the rows that it owns."

If there isn't an app or plugin that helps with that scenario, I'd
appreciate some pointers on how this could be implemented in a Django
website.

Cheers,

Fernando Correia

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



saving M2M with through table behavior change - (r.10189 vs. r.10190)

2009-08-23 Thread David Haas

Hi:

Yet again, I've run into a behavior change which seems to be linked to
svn revision 10190.  I've figured out a workaround for my code, but
I'm wondering if someone could provide some feedback if the change is
just a definition of previously undefined behavior, or a bug.

I've pasted some demo code here: http://dpaste.de/PUvT/

Basically, I have 2 models "A" and "B" with a many-to-many
relationship through "ABExtra".  I have a modelform where I can make
new instances of "B", with a inline modelformset for adding in
ABExtras.

In r. 10189, the pasted view code works just fine - I create my new
model B, pass it into my formset forms, then save the formsets.

In r.10190, the code throws an integrity error.  "abextra.modelb_id
may not be NULL"

I've worked around this bug by doing the following:

new_b = form.save()
for f in formset.forms:
  f.cleaned_data['ma'] = new_b
nbs= formset.save(commit=false)
for b in nbs:
  b.ma = new_b
  b.save()

But this seems a little redundant.  Can someone explain why the
behavior changed, or maybe a better way for me to save my form &
formset?

Thanks . . .

- D
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



request.FILES empty... only with IE!

2009-08-23 Thread OnurCelebi

Hi all,
I have a very strange behaviour. I have an upload form like this:

var upform = document.createElement('form');
upform.setAttribute('action','/engine/users/avatar/');
upform.setAttribute('enctype','multipart/form-data');
upform.setAttribute('method','post');

created dynamically with JS.
With Chrome and Firefox, it works fine. But with IE, I obtain an empty
request.FILES, it seems that the filename and its location (on clients
machine! ) goes to request.POST:

POST:,

Is this a bug?
Is there a way to fetch the file through POST's dictionary?

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Reusable/plugable apps integrations best practices

2009-08-23 Thread Richard Marko

Simple approach for this is to use try catch block to create proper
field like this:

from django.db import models

try:
from photos.models import Photo
photo_field = models.ManyToManyField(Photo)
except ImportError:
photo_field = None


class Standalone(models.Model):
name = models.CharField(max_length=5)
photos = photo_field


This way it is possible to look for a few common apps and add proper
fields. This will work nicely if you know what apps you are going to
install and after installation you run ./manage.py syncdb, but if you
need to add photos app _after_ the installation of Standalone model
things get little bit tricky as you have to create additional table
for that new m2m field (probably handled by schema migration app like
South)

I think this is pretty common problem in terms of portable/reusable
apps but as far as I know there are no solutions/guidelines for it.
For that reason I personally don't like Pinax as it's no more about
reusable apps, it's just collection of apps.

Solution I'm thinking about is something like application repository
with lots of guidelines how to write portable apps and solve
dependency issues etc.


On Aug 23, 1:36 am, "Chris H."  wrote:
> So I'm trying to get my head around making my small, tightly focused
> apps reusable.  I've done this, but right now still have
> "dependencies" between one another, that I'd like to remove.  For
> simplicity sake, I have an Articles, Events, and Photos app.
>
> Right now each Article has a photos.photo and events.event foreign key
> relationship and each event has a photos.photo_set fk relationship.
> Thus, as currently written all three apps are required.  I'd like to
> rework this such that the installation of each application is not
> required, and I'd think that additional functionality should live in
> the newer app.
>
> That is, when Photos gets "installed" it looks for Articles, if that
> is installed it hooks into the Photos model to supply the photo
> relationship.  And if Events is installed, it'll provide the photoset
> relationship.  If neither is installed, that's okay too, it just
> provides it's base functionality.  When Events gets installed, it
> looks for Articles, and if so allows you to relate an article to an
> event.
>
> Surely, this has done before, right?  Or am I approaching it wrong?
> My google foo fails me...what do I need to be searching for??

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Renaming an image to the SLUG after upload

2009-08-23 Thread The Danny Bos

Hey there, I've got the below code.
Can someone help me fill in the gaps to rename the image to the
'SLUG'?

In the end I'm hoping for images like so:

 ...com/books/book-title.jpg
 ...com/books/thumbs/book-title.jpg

Here's my save() definition from models.py:

def save(self):
super(Book, self).save()

image_path = '%s%s' % (settings.MEDIA_ROOT, str(self.cover))
path, filename = os.path.split(image_path)

thumb_name = '%s/thumbs/%s' % (path, filename)

gen_thumb(image_path, thumb_name, size=160)
self.thumb = '%s' % filename

super(Book, self).save()


--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Renaming an image to the SLUG after upload

2009-08-23 Thread The Danny Bos


Worked this one out.
For anyone interested ...

def save(self):
super(Book, self).save()

file_ext = os.path.splitext(str(self.cover.name))[1]
new_filename = '%s%s' % (self.slug, file_ext)
new_filepath = os.path.join(settings.MEDIA_ROOT, new_filename)
old_filepath = os.path.join(settings.MEDIA_ROOT, self.cover.name)
shutil.move(old_filepath, new_filepath)
self.cover.name = os.path.join('p/', new_filename)

super(Book, self).save()




On Aug 24, 10:36 am, The Danny Bos  wrote:
> Hey there, I've got the below code.
> Can someone help me fill in the gaps to rename the image to the
> 'SLUG'?
>
> In the end I'm hoping for images like so:
>
>  ...com/books/book-title.jpg
>  ...com/books/thumbs/book-title.jpg
>
> Here's my save() definition from models.py:
>
> def save(self):
>         super(Book, self).save()
>
>         image_path = '%s%s' % (settings.MEDIA_ROOT, str(self.cover))
>         path, filename = os.path.split(image_path)
>
>         thumb_name = '%s/thumbs/%s' % (path, filename)
>
>         gen_thumb(image_path, thumb_name, size=160)
>         self.thumb = '%s' % filename
>
>         super(Book, self).save()
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Reusable/plugable apps integrations best practices

2009-08-23 Thread Andrea Zilio

And what about doing the same way the Comment application (bundled
with Django) works?

I think that looking the way Comment app works could inspire you

On Aug 24, 12:39 am, Richard Marko  wrote:
> Simple approach for this is to use try catch block to create proper
> field like this:
>
> from django.db import models
>
> try:
>         from photos.models import Photo
>         photo_field = models.ManyToManyField(Photo)
> except ImportError:
>         photo_field = None
>
> class Standalone(models.Model):
>         name = models.CharField(max_length=5)
>         photos = photo_field
>
> This way it is possible to look for a few common apps and add proper
> fields. This will work nicely if you know what apps you are going to
> install and after installation you run ./manage.py syncdb, but if you
> need to add photos app _after_ the installation of Standalone model
> things get little bit tricky as you have to create additional table
> for that new m2m field (probably handled by schema migration app like
> South)
>
> I think this is pretty common problem in terms of portable/reusable
> apps but as far as I know there are no solutions/guidelines for it.
> For that reason I personally don't like Pinax as it's no more about
> reusable apps, it's just collection of apps.
>
> Solution I'm thinking about is something like application repository
> with lots of guidelines how to write portable apps and solve
> dependency issues etc.
>
> On Aug 23, 1:36 am, "Chris H."  wrote:
>
> > So I'm trying to get my head around making my small, tightly focused
> > apps reusable.  I've done this, but right now still have
> > "dependencies" between one another, that I'd like to remove.  For
> > simplicity sake, I have an Articles, Events, and Photos app.
>
> > Right now each Article has a photos.photo and events.event foreign key
> > relationship and each event has a photos.photo_set fk relationship.
> > Thus, as currently written all three apps are required.  I'd like to
> > rework this such that the installation of each application is not
> > required, and I'd think that additional functionality should live in
> > the newer app.
>
> > That is, when Photos gets "installed" it looks for Articles, if that
> > is installed it hooks into the Photos model to supply the photo
> > relationship.  And if Events is installed, it'll provide the photoset
> > relationship.  If neither is installed, that's okay too, it just
> > provides it's base functionality.  When Events gets installed, it
> > looks for Articles, and if so allows you to relate an article to an
> > event.
>
> > Surely, this has done before, right?  Or am I approaching it wrong?
> > My google foo fails me...what do I need to be searching for??
>
>
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Renaming an image to the SLUG after upload

2009-08-23 Thread Mike Ramirez
On Sunday 23 August 2009 05:36:13 pm The Danny Bos wrote:
> Hey there, I've got the below code.
> Can someone help me fill in the gaps to rename the image to the
> 'SLUG'?
>
> In the end I'm hoping for images like so:
>
>  ...com/books/book-title.jpg
>  ...com/books/thumbs/book-title.jpg
>
> Here's my save() definition from models.py:
>
> def save(self):
>   super(Book, self).save()
>
>   image_path = '%s%s' % (settings.MEDIA_ROOT, str(self.cover))
>   path, filename = os.path.split(image_path)
>
>   thumb_name = '%s/thumbs/%s' % (path, filename)
>
>   gen_thumb(image_path, thumb_name, size=160)
>   self.thumb = '%s' % filename
>
>   super(Book, self).save()
>


Try this:


def gen_thumb(image, size=160):
save_path = os.path.join(settings.MEDIA_ROOT, image)   
# gen thumb code here
image.save(save_path)
return

def save(self):
   thumb_path = os.path.join('books', 'thumbs', 'tn_%s' %(str(self.cover)))
   gen_thumb(thumb_path):
   self.thumb = thumb_path 
   super(Book, self).save()


First off, you should use os.path.join() when creating a file path; this will 
allow your code to be os independant as os.path.join() will set the right 
path seperators for the os. (Just a nit picky thing for os independance).

You should set the ImageField to a path relative to your settings.MEDIA_ROOT 
setting, the ImageField will automatically join[1] these together for use 
with thumb.path and you'll be able to use thumb.url for you img html tags 
(i.e.  ) since the url is 
actually the path relative to the MEDIA_ROOT/MEDIA_URL. 

You can alter the gen_thumb to return the relative path and use it in the 
upload_to= option of the ImageField and save yourself the headache, but the 
gen_thumb should follow the instructions in handling uploaded files[2].


Mike

[1] http://docs.djangoproject.com/en/dev/ref/models/fields/#filefield
[2] 
http://docs.djangoproject.com/en/dev/topics/http/file-uploads/#handling-uploaded-files
-- 
The trouble is, there is an endless supply of White Men, but there has
always been a limited number of Human Beings.
-- Little Big Man


signature.asc
Description: This is a digitally signed message part.


Re: Renaming an image to the SLUG after upload

2009-08-23 Thread The Danny Bos


Much nicer.
Thanks so much Mike ...


d


On Aug 24, 12:17 pm, Mike Ramirez  wrote:
> On Sunday 23 August 2009 05:36:13 pm The Danny Bos wrote:
>
>
>
>
>
> > Hey there, I've got the below code.
> > Can someone help me fill in the gaps to rename the image to the
> > 'SLUG'?
>
> > In the end I'm hoping for images like so:
>
> >  ...com/books/book-title.jpg
> >  ...com/books/thumbs/book-title.jpg
>
> > Here's my save() definition from models.py:
>
> > def save(self):
> >    super(Book, self).save()
>
> >    image_path = '%s%s' % (settings.MEDIA_ROOT, str(self.cover))
> >    path, filename = os.path.split(image_path)
>
> >    thumb_name = '%s/thumbs/%s' % (path, filename)
>
> >    gen_thumb(image_path, thumb_name, size=160)
> >    self.thumb = '%s' % filename
>
> >    super(Book, self).save()
>
> Try this:
>
> def gen_thumb(image, size=160):
>     save_path = os.path.join(settings.MEDIA_ROOT, image)  
>     # gen thumb code here
>     image.save(save_path)
>     return
>
> def save(self):
>    thumb_path = os.path.join('books', 'thumbs', 'tn_%s' %(str(self.cover)))
>    gen_thumb(thumb_path):
>    self.thumb = thumb_path
>    super(Book, self).save()
>
> First off, you should use os.path.join() when creating a file path; this will
> allow your code to be os independant as os.path.join() will set the right
> path seperators for the os. (Just a nit picky thing for os independance).
>
> You should set the ImageField to a path relative to your settings.MEDIA_ROOT
> setting, the ImageField will automatically join[1] these together for use
> with thumb.path and you'll be able to use thumb.url for you img html tags
> (i.e.  width="book.thumb.width" height="book.thumb.height" /> ) since the url is
> actually the path relative to the MEDIA_ROOT/MEDIA_URL.
>
> You can alter the gen_thumb to return the relative path and use it in the
> upload_to= option of the ImageField and save yourself the headache, but the
> gen_thumb should follow the instructions in handling uploaded files[2].
>
> Mike
>
> [1]http://docs.djangoproject.com/en/dev/ref/models/fields/#filefield
> [2]http://docs.djangoproject.com/en/dev/topics/http/file-uploads/#handli...
> --
> The trouble is, there is an endless supply of White Men, but there has
> always been a limited number of Human Beings.
>                 -- Little Big Man
>
>  signature.asc
> < 1KViewDownload
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Scaling Thumbnails instead of Cropping or Squashing.

2009-08-23 Thread The Danny Bos

Hey, so I've got this code to quickly create thumbnail files, below.
When I give it a value, it squishes the image to those dimensions, I'm
hoping to keep the correct proportions of a book instead of cropping
to a square or squashing.

Mainly as books can be portrait, landscape or square. So keep the
correct proportions, and make the tallest edge '120px'.

Know what I mean??


def gen_thumb(source, dest, size=120):
image = Image.open(source)
w,h = image.size

tn = image.resize((size,size), Image.ANTIALIAS)
tn.save(dest)
return dest
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Scaling Thumbnails instead of Cropping or Squashing.

2009-08-23 Thread Mike Ramirez
On Sunday 23 August 2009 06:48:33 pm The Danny Bos wrote:
> Hey, so I've got this code to quickly create thumbnail files, below.
> When I give it a value, it squishes the image to those dimensions, I'm
> hoping to keep the correct proportions of a book instead of cropping
> to a square or squashing.
>
> Mainly as books can be portrait, landscape or square. So keep the
> correct proportions, and make the tallest edge '120px'.
>
> Know what I mean??
>
>
> def gen_thumb(source, dest, size=120):
>   image = Image.open(source)
>   w,h = image.size
>
>   tn = image.resize((size,size), Image.ANTIALIAS)
>   tn.save(dest)
>   return dest

Try using image.thumbnail()  I've found this does keep the dimensions in 
proportion, regardless of the size passed to it.[1]

Mike
[1] http://www.pythonware.com/library/pil/handbook/image.htm

-- 
You are magnetic in your bearing.


signature.asc
Description: This is a digitally signed message part.


Re: Permissions issue with image uploads

2009-08-23 Thread Anogar

I missed a step - I did go ahead and chown it over to www-data, but I
needed to chmod x to u.

sudo chmod u+x uploads/

I thought 777 would be a little insecure, you really don't need to
give full permissions to group / others. I know it's probably not a
huge deal, but I figure it's best practices to keep permissions locked
to what they need to be. (i.e. drwx--r--r)

On Aug 23, 4:03 am, Ramdas S  wrote:
> chowning www-data will work. Make sure the directory has chown -R and chmod
> -R,
>
> suppose you are uploading to media/images
>
> chown -R www-data media/images
> chmod -R 777 media/images
>
>
>
> On Sun, Aug 23, 2009 at 11:17 AM, Anogar  wrote:
>
> > I'm trying to implement a simple image upload inside my blog, and I
> > had it working on my local machine, but when I deployed it threw this
> > error:
>
> > OSError at /path/
> > (13, 'Permission denied')
> > 
>
> > So, it's clearly a permissions issue - but I can't quite figure out
> > how to fix it. Just to confirm my idea I chmod'd the permissions to
> > 777 - and the whole thing suddenly works perfectly, but that's
> > obviously not a permanent solution.
>
> > I tried chown'ing the file over to www-data which is my Apache
> > process, but that didn't work either. Who should own my uploads
> > folder?
>
> > Thanks!
>
> > -Ryan
>
> --
> Ramdas S
> +91 9342 583 065
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: multi-tenant website

2009-08-23 Thread Daniel Hilton

You might have alook at the saas kit which is availble on github,
which does subscription billing, subdomain handling and multi user
accounts. You could then write a decorator to wrap any db request to
perform a test to check that only rows that are linked to that
requesting user are returned or some custom managers.

HTH
dan

On Sunday, August 23, 2009, Fernando  wrote:
>
> Is there a Django app that helps with handling multitenancy, that is,
> having a single website and a single database serving multiple
> organizations in a software-as-a-service fashion while avoiding one
> tenant to interact with another's data?
>
> I'm talking about the "Shared database, shared schema" scenario like
> described in this article:
>
> http://msdn.microsoft.com/en-us/library/aa479086(loband).aspx#mlttntda_topic2
>
> "In this approach, all tenants share the same set of tables, and a
> Tenant ID associates each tenant with the rows that it owns."
>
> If there isn't an app or plugin that helps with that scenario, I'd
> appreciate some pointers on how this could be implemented in a Django
> website.
>
> Cheers,
>
> Fernando Correia
>
> >
>

-- 
Dan Hilton

www.twitter.com/danhilton
www.DanHilton.co.uk


--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Error in setting up psycopg2

2009-08-23 Thread Thomas Guettler

Hi Simon,



Simon Lee schrieb:
> Thank you for being patient in helping me out.
> 
> I checked it /etc/passwd and found this line which I think is the
> reference for UID 70
> 
> _www:*:70:70:World Wide Web Server:/Library/WebServer:/usr/bin/false
> 
> I did "su - _www" (I hope I did this right). It still asked for a
> password which I entered my root password (the only password that I
> know) and it complained that the password is wrong.

You seem to be a beginner with unix, too. That makes it more difficult,
but soon you will know the basics.

Unix user root can "su" to every account without password:

# get root:
u...@host> su -
r...@host> su - _www
w...@host>
Now you can check if this user can read the files:
more //tz.py


If this does not work. Maybe you need to change the last line in /etc/passwd
of user _www. /usr/bin/false means he has no login-shell. Change this
to /usr/bin/bash (or you preferred shell).

If you get "permission denied" while accessing the python files as www you need 
to run
"chmod -R a+rX  /..."

  Thomas

-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---