Re: Django 1.5 AbstractBaseUser with char primary key not JSON serializable

2013-02-15 Thread Russell Keith-Magee
Hi Kaloian,

Ah - you've just fired a neuron in my brain… This is a known issue, and
it's not just the permission_required decorator.

See ticket #14881.

I don't remember the permission_required decorator itself being a problem
at that time (not saying it isn't -- just that it wasn't reported as such,
or I don't recall it being reported as such) -- the issues that were being
reported were with admin URLs for User objects, and for password reset
tokens.

So - the short answer is that yes, non-integer primary keys will cause some
problems with custom User objects. This is something we should probably
document as a limitation. I've just added a note to this effect in the docs.

This doesn't mean you have to give up having the api_key as a unique
identifier; you just need to have the api_key *in addition* to the integer
primary key; Django's internals will use the integer primary key, and your
code can do lookups based on the API key.

Of course, we're also open to patches to fix the situation :-)

Yours,
Russ Magee %-)

On Fri, Feb 15, 2013 at 9:48 PM, Kaloian  wrote:

>
> Hi Russel I got into another small issue related to the character primary
> key of the user model.
> When I try to use the permission_required decorator on that model I got
> the following error.
>
> Exception Value:
>
> invalid literal for int() with base 10: 
> '3DDz0Vi7zonFDq9JfByKkeparghaWwupVwbMCbL7JHo'
>
>  Exception Location: 
> /usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py
> in get_prep_value, line 554
> Here is the latest definition of my model:
>
> class Merchant(AbstractBaseUser,PermissionsMixin):
> """User with app settings."""
> id = models.CharField(max_length=256, primary_key=True)
> email = models.EmailField(unique=True, db_index=True)
>
> company_name = models.CharField(max_length=256)
> website = models.URLField()
> description = models.TextField(blank=True)
> #api_key = models.CharField(blank=True, max_length=256,
> primary_key=True)
>
> USERNAME_FIELD = 'email'
> REQUIRED_FIELDS = ['company_name','website']
>
> objects = MerchantManager()
>
>
> class Meta:
> verbose_name = _('Merchant')
> verbose_name_plural = _('Merchants')
>
>
>
>
> I can easily find workaround for that problem by writing custom decorator for 
> example but I am not sure this is supposed to be this way. Or may be I am 
> missing something here ?
>
> Thanks,
> Kaloian
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




need help for my project

2013-02-15 Thread wassim bchini
hello 
i have a project with Django ; my project is to built a web application to 
administrate  FTP server , i have the engine on python but i haven't 
information how to render the graphical part (pages,forms,...) ,so i want 
some information to create the GUI part and to linked with the engine , 
please help me and excuse my poor English , thx :)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




i need help

2013-02-15 Thread wassim bchini
hello ;
i have a Project and i'm beginner on Django ; my project is to build web 
application to administrate FTP server , i have the program 
of administration on python (engine) and i need some information how to 
render the web application interface (pages,forms,...)  to work with engine 
,  please excuse  my poor English  :) ,thx 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django 1.5 & Python 3 - porting packages to Python3

2013-02-15 Thread Russell Keith-Magee
Hi Thomas,

I'm not aware of any specific efforts to push Python 3 porting. Like Django
itself, the ecosystem of Django (and Python) packages is organised by
volunteers, so unless volunteers spend the time and effort to port, nothing
gets done. You're ahead of the curve in porting all your Django code to
Python 3; the rest of the community hasn't had the same set of itches, so
they haven't caught up yet.

Speaking on behalf of the DSF -- if anyone has any good ideas on how we
could speed up this process, let me know.

In the meantime, if you want Python 3 ports of these projects, remember
that this is open source, so you can make it happen. Fork their repos, and
give them patches. I'm sure they wouldn't object to the help.

Yours,
Russ Magee %-)

On Fri, Feb 15, 2013 at 4:35 PM, Thomas Weholt wrote:

> Hi,
>
> As a Norwegian user of Django and python user I've spent countless
> hours dealing with unicode-problems. As I ported DSE to Python 3 a
> while ago I also discovered that all my unicode problems were solved
> if I started using Python 3. Probably old news to most of you, or
> maybe not even relevant, but it's a make-or-break-situation for me and
> my potential users and customers. So all my latest django-based
> projects have been developed using Python 3.3 with great success.
>
> But the only problem now is the lack of python-packages supporting
> Python 3, mainly PIL ( or the pil-fork pillow ), django-debug-toolbar,
> django-celery etc.
>
> Are there any focus in the community on getting packages ready for python3?
>
> --
> Mvh/Best regards,
> Thomas Weholt
> http://www.weholt.org
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Using template fragment caching *inside* a sitewide cache: possible?

2013-02-15 Thread Matt Andrews
I tried using the approach above (template fragment cache everywhere 
instead of sitewide) and the same problem was there: the inner cache didn't 
reflect cachebusting changes.

I ended up rewriting the code to pull the view fragments via AJAX (which 
did respect the cachebusting). You can see the results 
here: http://www.scenepointblank.com/ (it's the "popular right now" tabbed 
widget near the bottom right.

On Thursday, 14 February 2013 17:19:28 UTC, Matt Andrews wrote:
>
> Hi Tom,
>
> Yep, you've got the problem right. Reading it back that way I see the 
> issue much more clearly...
>
> One approach I thought of: what if, instead of the sitewide caching, I 
> used template-fragment caching for *every* view (there aren't that many) 
> and invalidated the relevant ones along with the nested caches when needed 
> (there are probably only five or so views where this would need to happen)?
>
> I'm on shared hosting so I don't think Varnish is going to be a 
> possibility...
>
> thanks!
>
> On Thursday, 14 February 2013 16:02:53 UTC, Tom Evans wrote:
>>
>> On Mon, Feb 11, 2013 at 1:42 PM, Matt Andrews  
>> wrote: 
>> > Hi all, 
>> > 
>> > I've been experimenting with an expensive query I need to call 
>> (essentially 
>> > grabbing data from some Google APIs). I tried this experiment: 
>> > 
>> > A sitewide cache with a long (days) expiry time 
>> > A template fragment with its own separate cache inside a view cached by 
>> the 
>> > sitewide cache -- this fragment simply displays the current time. 
>> > A view function which clears the named template fragment cache. 
>> > 
>> > The behaviour I expected was that on first pageload, the fragment would 
>> > display the time of page render, and all subsequent reloads would 
>> display 
>> > the same time. This was true. 
>> > 
>> > The second part, though, was that I expected to be able to call the 
>> view 
>> > function to clear the fragment cache and then reload the page to see 
>> the 
>> > time update. This didn't happen. 
>> > 
>> > Is it possible to achieve this behaviour? Essentially I want to run a 
>> > background cron task which just hits the Google API and updates my 
>> cached 
>> > fragments - the Google data changes every 15 minutes but the sitewide 
>> cache 
>> > has several hours timeout, normally. 
>> > 
>> > Hope this makes sense. 
>> > 
>> > Matt 
>> > 
>>
>> Hi Matt 
>>
>> Can I restate the problem to see if I am getting it right? 
>>
>> You have a page fragment, 'FRAG', stored in the cache. 
>> You have a page, 'PAGE', using that fragment stored in the cache. 
>> You update 'FRAG' in the cache. 
>> You reload 'PAGE', and it has the old contents of 'FRAG' instead of 
>> the updated one. 
>>
>> If so, this is to be expected. The site cache caches entire responses, 
>> with a key derived from that request. When a new request comes in, a 
>> key is generated from that request. If the key is found in the cache, 
>> the cached response is returned. 
>>
>> At no point does the cache know that one cache entry is built using 
>> another, or that invalidating the fragment should invalidate any page 
>> containing that fragment. 
>>
>> One potential solution is to use something like Varnish, an HTTP 
>> accelerator/cache that has support for ESI - Edge Side Includes - that 
>> allow you to build up responses from multiple components, and 
>> intelligently cache the components. Eg, an example of what you are 
>> trying to do in Varnish using ESI: 
>>
>> https://www.varnish-cache.org/trac/wiki/ESIfeatures#Anesi:includeexample 
>>
>> Alternatively, I may have completely misunderstood this :) 
>>
>> Cheers 
>>
>> Tom 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: django generate pdf with tables and charts

2013-02-15 Thread Christian Schmitt
Maybe this Issue could help you 
http://code.google.com/p/wkhtmltopdf/issues/detail?id=948
Also pass --enable javascript and the javascript delay to wkhtmltopdf

Am Donnerstag, 14. Februar 2013 15:45:38 UTC+1 schrieb Jaimin Patel:
>
> Sure.
>
> I had tried to render PDF with pisa,
>
> template = get_template(template_src)
> context = Context(context_dict)
> html  = template.render(context)
> result = StringIO.StringIO()
>
> pdf = pisa.pisaDocument(StringIO.StringIO(html.encode("ISO-8859-1")), 
> result, link_callback=fetch_resources)
> if not pdf.err:
> return HttpResponse(result.getvalue(), mimetype='application/pdf')
> return HttpResponse('Errors%s' % escape(html))
>
> Also tried with wkhtmltopdf -
>
> from wkhtmltopdf.views import PDFTemplateResponse
> ..
> return PDFTemplateResponse(request, 'pdf/pdftemplate.html', {
> 'pagesize':'A4',
>'user': results['user'],
>'question': results['question_obj'],
>})
>
> In both cases it doesn't render the elements which I am populating with 
> help of onload javascript function.
>
> On Wednesday, February 13, 2013 10:45:40 PM UTC-5, ovnicraft wrote:
>>
>>
>>
>>
>> On Sun, Feb 10, 2013 at 11:10 AM, Jaimin Patel wrote:
>>
>>> I am trying to generate pdf using django template, also need some 
>>> support of javascript code. I have tried PISA, ReportLib and wkhtmltopdf 
>>> but it seems that it doesn't wait for Javascript. 
>>
>>
>> Hello, can you explain us better what you means with *does not wait for 
>> JS* ? 
>> I understand you say: pdf is rendered w/o running JS code.
>>
>> Regards, 
>>
>>>
>>> Can someone suggest good solution or example?
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>  
>>>  
>>>
>>
>>
>>
>> -- 
>> Cristian Salamea
>> @ovnicraft 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: The problem with storing relative paths

2013-02-15 Thread Robin Fordham
Hi jonni,

How about something like;

FORMTEMPLATE_PATH = os.path.join(settings.PROJECT_PATH, 'templates/forms'

class Somemodel(models.Model):
  formtemplate = FilePathField(path='FORMTEMPLATE_PATH', 
match=".\*.htm[l]")
  .
  .


On Friday, February 15, 2013 4:14:44 PM UTC, JZint wrote:
>
> Hello!
>
> So this is what i wanna do:
>
> I have built a model with an admin interface for letting the user create 
> his own site. it has following fields:
>
> name = models.CharField(max_length = 50)
> formtemplate = 
> FilePathField(path='/path/to/project/myforms/templates/forms', 
> match=".\*.htm[l]")
> thankyoutemplate = 
> FilePathField(path='/path/to/project/myforms/templates/forms', 
> match=".\*.htm[l]", blank=True)
> slug = models.CharField(max_length = 50)
>
> He should be able to upload his template-files to that folder and 
> afterwards selecting it in the model admin. but the database is storing the 
> absolute path which means, after putting the project to another path or 
> system all paths in the database are useless.
> id like to avoid that and looked for solutions. I would like the database 
> to store only the relative part and my code should apped it to 
> settings.PROJECT_PATH ... Am i thinking it right or is there a more 
> "django-like" way to do it
>
> There already is a implementation of a RelativeFilePathField but several 
> people told me there are better ways to accomplish what i wanna do...
>
> Thank you very much for your help.
>
> Jonni
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django project - Allow users to write a custom function and store in DB

2013-02-15 Thread Robin Fordham
> Very cool.
>
> Please post some notes about whole thign.

Not as cool as it may sound, more me playing and trying to learn a bit
of digital electronics and improve my coding skills.

Video of my setup;

http://youtu.be/MFISZPqdbD4

My code (note this is just the python object, django side of it is
VERY experimental still!);

https://bitbucket.org/gingebot/raspberry-pi-i2c-port-expander-play/overview

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django project - Allow users to write a custom function and store in DB

2013-02-15 Thread George Silva
Very cool.

Please post some notes about whole thign.


On Fri, Feb 15, 2013 at 2:34 PM, Robin Fordham  wrote:

> Hi guys,
>
> Thanks for all the pointers!
>
> George / Bob - That's exactly the pointer I needed 'exec' or 'eval'
>
> Ryan -  Celery is something I have been looking into, but I hadn't thought
> of using it to to put processes in a sandbox; I have a raspberry pi project
> with an array of LEDs and am building a Django front end to control them,
> few of the chaser functions are while loops which would hang up everything,
> so pushing them to a subprocess over celery should be ideal. BTW django +
> nginx + fastcgi runs surprisingly well on a pi!
>
> Thanks for the help guys!
>
> Robin.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
George R. C. Silva
SIGMA Consultoria

http://www.consultoriasigma.com.br/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django project - Allow users to write a custom function and store in DB

2013-02-15 Thread Robin Fordham
Hi guys,

Thanks for all the pointers!

George / Bob - That's exactly the pointer I needed 'exec' or 'eval'

Ryan -  Celery is something I have been looking into, but I hadn't thought 
of using it to to put processes in a sandbox; I have a raspberry pi project 
with an array of LEDs and am building a Django front end to control them, 
few of the chaser functions are while loops which would hang up everything, 
so pushing them to a subprocess over celery should be ideal. BTW django + 
nginx + fastcgi runs surprisingly well on a pi!

Thanks for the help guys!

Robin.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Need help with GeoDjango distance query.

2013-02-15 Thread mack the finger
http://stackoverflow.com/questions/14889780/distance-query-within-a-certain-distance-based-on-value-in-joined-table

Basically I want all objects within a certain distance, AS WELL as within 
each object's preferred distance.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




The problem with storing relative paths

2013-02-15 Thread JZint
Hello!

So this is what i wanna do:

I have built a model with an admin interface for letting the user create 
his own site. it has following fields:
   
name = models.CharField(max_length = 50)
formtemplate = 
FilePathField(path='/path/to/project/myforms/templates/forms', 
match=".\*.htm[l]")
thankyoutemplate = 
FilePathField(path='/path/to/project/myforms/templates/forms', 
match=".\*.htm[l]", blank=True)
slug = models.CharField(max_length = 50)

He should be able to upload his template-files to that folder and 
afterwards selecting it in the model admin. but the database is storing the 
absolute path which means, after putting the project to another path or 
system all paths in the database are useless.
id like to avoid that and looked for solutions. I would like the database 
to store only the relative part and my code should apped it to 
settings.PROJECT_PATH ... Am i thinking it right or is there a more 
"django-like" way to do it

There already is a implementation of a RelativeFilePathField but several 
people told me there are better ways to accomplish what i wanna do...

Thank you very much for your help.

Jonni

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Designing the email processing system. What path should I follow?

2013-02-15 Thread Tom Evans
On Fri, Feb 15, 2013 at 12:57 PM, Andre Lopes  wrote:
> Hi all,
>
> I'm building a Django website. Currently I'm searching for the best
> way to design the email processing system.
>
> The website is a Ads site. I need to send emails in a regular basis to
> the users. I'm looking for 20 or 30 e-mails hour for now.
>
> In other projects, I've been using a database table to handle the
> e-mail processing. But when I started to develop in Django I have read
> some articles about Celery/RabbitMQ. What I want to know is if adding
> Celery/RabbitMQ to the e-mail processing system is a must or I adding
> this I will only add another layer of complexity.

The problem is that if you don't use Celery, what you end up doing is…

>
> The solution that I've designed in another project uses a database
> table and a cronjob running every 5 or 10 minutes to handle this. The
> Database table is very simple. Looks like this:
>
> [code]
> CREATE TABLE "atem_emails_envios" (
> "id_email_envio" int4 NOT NULL,
> "id_email_msg" varchar(20) NOT NULL,
> "dat_inserted" timestamp NOT NULL,
> "dat_sended" timestamp,
> "try_number" int4,
> "max_tries" int4 NOT NULL,
> "email_from" varchar(500) NOT NULL,
> "email_to" varchar(500) NOT NULL,
> "email_cc" varchar(500),
> "email_bcc" varchar(500),
> "email_subject" varchar(500) NOT NULL,
> "email_msg" text NOT NULL,
> "error_msg" text,
> "i_started" timestamp,
> "pid" int4,
> "coment" varchar(2000),
> "id_utiliz_ins" varchar(45),
> "id_utiliz_upd" varchar(45),
> "data_ult_actual" timestamp,
>   PRIMARY KEY("id_email_envio"),
>   CONSTRAINT "Ref_atem_emails_envios_to_atem_mensagens_email" FOREIGN
> KEY ("id_email_msg")
> REFERENCES "atem_mensagens_email"("id_email_msg")
> MATCH SIMPLE
> ON DELETE NO ACTION
> ON UPDATE NO ACTION
> NOT DEFERRABLE
> );
> [/code]
>
> When an e-mail is being processed I just store the PID to the table to
> avoid collisions.

… this.

>
> My question goes in this direction. I've been using this table to
> process e-mails in a website with low traffic, and works well. What
> advantages I have using a Queue manager like Celery and a broker like
> RabbitMQ? What benefits I will gain using a solution like
> Celery/RabbitMQ?
>

You get a robust queuing system for processing tasks asynchronously
that will be understood by anyone who has used celery. If they haven't
used celery, then they can learn it, and then on the next project that
requires asynchronous handling of tasks, they don't need to learn the
quirks and deficiencies of yet another hand rolled queueing system.

You get tight integration into Django.

You get tools for monitoring and maintaining your queues.

You get the comfort that hundreds of billions of messages have
successfully passed through the same setup.

You don't have to write and maintain a queueing system. You don't have
to subsequently expand it to do multiprocessing. You don't have to fix
the inevitable bugs!

You get a proper AMQP stack which heterogeneous components can
communicate with each other through, if you have the need. For
instance, actions on your django site could send AMQP messages to a
node.js instance instructing it to push data to a client over
websockets.

(I swear there is an awesome blog post that explains all of this
better than I have, but my google-fu is weak today apparently!)

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django project - Allow users to write a custom function and store in DB

2013-02-15 Thread bobhaugen
I found this useful in doing something like that:
http://lybniz2.sourceforge.net/safeeval.html
http://effbot.org/zone/librarybook-core-eval.htm

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Bootstrap does not format my templates..

2013-02-15 Thread Ryan Nowakowski
On Thu, Feb 14, 2013 at 06:41:24PM -0800, galva...@hotmail.com wrote:
> Hi Guys
> 
> I am learning Django and trying to use Bootstrap, I already download 
> bootstrap and put it under 'D:\django14\projects\nomina\nom_mex\static', I 
> have Django 1.4 and use the developer server "runserver". According 
> Django's documentation says referent it I need to use STATICFILES_DIRS and 
> STATIC_URL parameters in my settings.py what else do I have to take in 
> count to run bootstrap ?, It seems I have something wrong in my settings.py 
> or may be in my urls.py,  I left my project's files hoping somebody can 
> help me, the template I am testing is the index.html.
> 
> I will appreciate any observations or suggestions...
> 
> Thanks in advance.
> 
> Jose Galvan

When you "view source" in your browser does the Bootstrap CSS URL look
correct?  When you copy and paste the Bootstrap CSS URL into your browser
do you see the Bootstrap CSS?

- Ryan

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django project - Allow users to write a custom function and store in DB

2013-02-15 Thread Ryan Nowakowski
Robin,

You could store that code as a string in the database.  Then to run it
you could execute it asynchronously using something like django-celery.
Have celery fork off a separate python process for each instance of code
execution.

By running code asynchronously, badly behaved code(loop forever, long
sleeps) aren't a deal breaker.  By forking off a separate process you
can do all kinds of things to create a security sandbox.  You could run
the process in a chroot or even a virtual machine.

- Ryan

On Fri, Feb 15, 2013 at 11:14:50AM -0200, George Silva wrote:
> Hi Robin,
> 
> I've tried doing this and abandoned the idea. The code still works, but
> it's not being actively used.
> 
> I wrote this to work as a part of an ETL process custom made in Django.
> Basically I had field mappings and transformations, some of them fixed
> (conversion from str to int and the like) and custom transformations for
> each field and each row, that could be calculated by a user defined
> function.
> 
> There are MANY potential problems for this approach, but you should be fine
> IF THE environment is controlled. That means:
> 
> 1 - only super-authorized users can write these functions
> 2 - you can TRY to find dangerous code. that means finding whiles (while 1:
> pass can put you to sleep, for instance), dangerous imports, etc.
> 3 - I've used a common interface for the function. If the interface
> (parameters) are not the same, it won't work.
> 4 - namespace/sandbox the exec command
> 
> this is how i basically did it:
> 
> if not self._metodo_conversao:
> self._metodo_conversao = compile(self.metodo_conversao,
> "", "exec")
> 
> ns = {"__builtins__": __builtins__, "entrada": entrada,
> "campo_novo": campo_novo}
> exec self._metodo_conversao in ns
> 
> self being the model instance and _metodo_conversao being a string, which
> contained the code.
> 
> After all of these considerations, it is still UNSAFE to do such a thing
> for the general public. In my case this was a ETL process, so we might need
> different conversions. We found out that we only needed a few, so it wasn't
> wortht the trouble.
> 
> 
> 
> 
> 
> On Fri, Feb 15, 2013 at 11:03 AM, Robin Fordham  wrote:
> 
> > Hi,
> >
> > I want to be able to allow users to write a custom function/object and
> > save it to the database, so django can call up the function when needed.
> >
> > I am aware of potential issues of users writing functions that could break
> > and/or exploit my app, this for internal use and can write some tests in if
> > needed.
> >
> > So essentially I want to parse a string and convert it to a function.
> >
> > Anyone got any pointers to send me in the right direction?
> >
> > Thanks.
> >
> > Robin.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to django-users+unsubscr...@googlegroups.com.
> > To post to this group, send email to django-users@googlegroups.com.
> > Visit this group at http://groups.google.com/group/django-users?hl=en.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
> >
> 
> 
> 
> -- 
> George R. C. Silva
> SIGMA Consultoria
> 
> http://www.consultoriasigma.com.br/
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
> 
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django 1.5 AbstractBaseUser with char primary key not JSON serializable

2013-02-15 Thread Kaloian

Hi Russel I got into another small issue related to the character primary 
key of the user model. 
When I try to use the permission_required decorator on that model I got the 
following error. 

Exception Value: 

invalid literal for int() with base 10: 
'3DDz0Vi7zonFDq9JfByKkeparghaWwupVwbMCbL7JHo'

 Exception Location: 
/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py 
in get_prep_value, line 554
Here is the latest definition of my model: 

class Merchant(AbstractBaseUser,PermissionsMixin):  
"""User with app settings."""
id = models.CharField(max_length=256, primary_key=True)
email = models.EmailField(unique=True, db_index=True)
company_name = models.CharField(max_length=256)
website = models.URLField()
description = models.TextField(blank=True)
#api_key = models.CharField(blank=True, max_length=256, 
primary_key=True)   
  
USERNAME_FIELD = 'email'  
REQUIRED_FIELDS = ['company_name','website']

objects = MerchantManager()

class Meta:
verbose_name = _('Merchant')
verbose_name_plural = _('Merchants')




I can easily find workaround for that problem by writing custom decorator for 
example but I am not sure this is supposed to be this way. Or may be I am 
missing something here ? 

Thanks,
Kaloian


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Django project - Allow users to write a custom function and store in DB

2013-02-15 Thread Robin Fordham
Hi,

I want to be able to allow users to write a custom function/object and save 
it to the database, so django can call up the function when needed.

I am aware of potential issues of users writing functions that could break 
and/or exploit my app, this for internal use and can write some tests in if 
needed.

So essentially I want to parse a string and convert it to a function.

Anyone got any pointers to send me in the right direction?

Thanks.

Robin.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Designing the email processing system. What path should I follow?

2013-02-15 Thread Andre Lopes
Hi all,

I'm building a Django website. Currently I'm searching for the best
way to design the email processing system.

The website is a Ads site. I need to send emails in a regular basis to
the users. I'm looking for 20 or 30 e-mails hour for now.

In other projects, I've been using a database table to handle the
e-mail processing. But when I started to develop in Django I have read
some articles about Celery/RabbitMQ. What I want to know is if adding
Celery/RabbitMQ to the e-mail processing system is a must or I adding
this I will only add another layer of complexity.

The solution that I've designed in another project uses a database
table and a cronjob running every 5 or 10 minutes to handle this. The
Database table is very simple. Looks like this:

[code]
CREATE TABLE "atem_emails_envios" (
"id_email_envio" int4 NOT NULL,
"id_email_msg" varchar(20) NOT NULL,
"dat_inserted" timestamp NOT NULL,
"dat_sended" timestamp,
"try_number" int4,
"max_tries" int4 NOT NULL,
"email_from" varchar(500) NOT NULL,
"email_to" varchar(500) NOT NULL,
"email_cc" varchar(500),
"email_bcc" varchar(500),
"email_subject" varchar(500) NOT NULL,
"email_msg" text NOT NULL,
"error_msg" text,
"i_started" timestamp,
"pid" int4,
"coment" varchar(2000),
"id_utiliz_ins" varchar(45),
"id_utiliz_upd" varchar(45),
"data_ult_actual" timestamp,
  PRIMARY KEY("id_email_envio"),
  CONSTRAINT "Ref_atem_emails_envios_to_atem_mensagens_email" FOREIGN
KEY ("id_email_msg")
REFERENCES "atem_mensagens_email"("id_email_msg")
MATCH SIMPLE
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE
);
[/code]

When an e-mail is being processed I just store the PID to the table to
avoid collisions.

My question goes in this direction. I've been using this table to
process e-mails in a website with low traffic, and works well. What
advantages I have using a Queue manager like Celery and a broker like
RabbitMQ? What benefits I will gain using a solution like
Celery/RabbitMQ?

Please give me some clues.

Best Regards,

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django throws ImproperlyConfigured error when loading URLconf on startup

2013-02-15 Thread Andrei
Have you guys found a solution for this? This happens on one of our servers 
that uses Django CMS and relies on gevent worker. Others using gevent work 
fine. I am investigating other differences. Any suggestions?

Django==1.4.3
django-cms==2.3.1
eventlet==0.9.17
gevent==0.13.7
greenlet==0.4.0
gunicorn==0.14.6

Andrei


On Monday, December 3, 2012 6:48:12 AM UTC+1, Garth Cumming wrote:
>
> I've noticed this same behaviour as well but only with a higher loaded 
> production server and using the gunicorn gevent class, i've never seen this 
> happen with a sync class.
>
> I'll take a wild guess that gevent worker class is handling requests 
> before django has had a chance to initialize. Perhaps django does some sort 
> of blocking on startup and the gevent monkey patching prevents this 
> blocking behaviour on startup. Just a wild guess.
>
> On Wednesday, November 28, 2012 3:03:10 PM UTC-8, Michael Dippery wrote:
>>
>> I have a Django app running on a production server. It is handled with 
>> gunicorn 0.14.2 behind nginx. When I reload the app (by reloading the 
>> gunicorn workers), I get this error: 
>>
>> --- 
>> Traceback (most recent call last): 
>>
>>  File 
>> "/opt/app/venv/myapp/lib/python2.6/site-packages/django/core/handlers/base.py",
>>  
>> line 101, in get_response 
>>request.path_info) 
>>
>>  File 
>> "/opt/app/venv/myapp/lib/python2.6/site-packages/django/core/urlresolvers.py",
>>  
>> line 250, in resolve 
>>for pattern in self.url_patterns: 
>>
>>  File 
>> "/opt/app/venv/myapp/lib/python2.6/site-packages/django/core/urlresolvers.py",
>>  
>> line 283, in _get_url_patterns 
>>raise ImproperlyConfigured("The included urlconf %s doesn't have any 
>> patterns in it" % self.urlconf_name) 
>>
>> ImproperlyConfigured: The included urlconf myapp.urls doesn't have any 
>> patterns in it 
>> --- 
>>
>> Others with this problem have commonly noted that it occurs while using 
>> reverse in a URLconf, but I am not using reverse in any URLconfs (nor are 
>> they used in any third-party apps). Also, this error only occurs in 
>> production -- never in development (using the Django dev server) or on my 
>> staging server (also using gunicorn 0.14.2 behind nginx). It also doesn't 
>> seem to cause trouble with the site at any other time then during reloads. 
>> And it only happens for the first 10-20 requests on the website (which 
>> makes me wonder if it's some sort of race condition, perhaps). 
>>
>> Any ideas what's causing the problem?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Updated Django by Example tutorials

2013-02-15 Thread Rainy


On Monday, February 11, 2013 11:24:57 PM UTC-5, Rainy wrote:
>
> Hi, I've started updating Django by Example tutorials for django version 
> 1.5 and using class-based views.
> I have posted 3 tutorials so far; 3 more will be added soon:
>
> http://lightbird.net/dbe2/
>
> I hope these will prove to be useful.. please let me know of any issues / 
> ways to improve the guide.
>
>  - rainy
>


I have added a new tutorial -- Issues Tracker:  
http://lightbird.net/dbe2/issues.html

It contains a nice example of making custom multi-fields. 

 - rainy

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Django 1.5 & Python 3 - porting packages to Python3

2013-02-15 Thread Thomas Weholt
Hi,

As a Norwegian user of Django and python user I've spent countless
hours dealing with unicode-problems. As I ported DSE to Python 3 a
while ago I also discovered that all my unicode problems were solved
if I started using Python 3. Probably old news to most of you, or
maybe not even relevant, but it's a make-or-break-situation for me and
my potential users and customers. So all my latest django-based
projects have been developed using Python 3.3 with great success.

But the only problem now is the lack of python-packages supporting
Python 3, mainly PIL ( or the pil-fork pillow ), django-debug-toolbar,
django-celery etc.

Are there any focus in the community on getting packages ready for python3?

-- 
Mvh/Best regards,
Thomas Weholt
http://www.weholt.org

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Python trademark at risk in Europe: We need your help!

2013-02-15 Thread Jani Tiainen

I'll post this here since this will touch some of us as well:

http://pyfound.blogspot.fi/2013/02/python-trademark-at-risk-in-europe-we.html

And small quote from beginning of that post:

"For anyone who works in a company that has an office in a EU Community 
member state, we need your help.


There is a company in the UK that is trying to trademark the use of the 
term "Python" for all software, services, servers... pretty much 
anything having to do with a computer."




--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.