[Apache] Trouble deploying my web app with mod_python

2012-11-14 Thread Issam Outassourt
Hi all,
I've got a problem deploying my new app that i designed on my personal
server that i run on my computer and i would like some help to deal with
this.

Here's the problem. You can see down here what happens when I try to
visualize my home page :

ServerName: '127.0.1.1'
DocumentRoot:   '/var/www'

URI:'/'
Location:   '/'
Directory:  None
Filename:   '/var/www/'
PathInfo:   ''

I get this due to the PythonDebug On that's on my apache2.conf file, from
which i've got these lines which normally set the server to append the
django developped app (from what i understood) :

LoadModule python_module /usr/lib/apache2/modules/mod_python.so


SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonDebug On
PythonPath "['/home/issam/Workspace/Django/DjangoCode/',
'/home/issam/Workspace/Django/DjangoCode/mysite/'] + sys.path"


to help you out there, my settings.py file lives in
/home/issam/Workspace/Django/DjangoCode/mysite/mysite

I wish i could get help from you guys and that you've got sufficient
details to help me out with this.

Thanks in advance.

-- 
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: [Apache] Trouble deploying my web app with mod_python

2012-11-14 Thread Issam Outassourt
Well
I started discovering django through the djangobook.
I'll try wsgi and let you know.
Thabks for your help
Le 14 nov. 2012 14:21,  a écrit :

> **
> Hi Isaam!
>
> Do you have a specific reason for using mod_python?
>
> This module is old and deprecated. The recommended way is to use other
> modules, many people use mod_wsgi which is really simple to deploy and use.
>
> HTH
>
> Jirka
> ------
> *From: * Issam Outassourt 
> *Sender: * django-users@googlegroups.com
> *Date: *Wed, 14 Nov 2012 11:45:40 +0100
> *To: *
> *ReplyTo: * django-users@googlegroups.com
> *Subject: *[Apache] Trouble deploying my web app with mod_python
>
> Hi all,
> I've got a problem deploying my new app that i designed on my personal
> server that i run on my computer and i would like some help to deal with
> this.
>
> Here's the problem. You can see down here what happens when I try to
> visualize my home page :
>
> ServerName: '127.0.1.1'
> DocumentRoot:   '/var/www'
>
> URI:'/'
> Location:   '/'
> Directory:  None
> Filename:   '/var/www/'
> PathInfo:   ''
>
> I get this due to the PythonDebug On that's on my apache2.conf file, from
> which i've got these lines which normally set the server to append the
> django developped app (from what i understood) :
>
> LoadModule python_module /usr/lib/apache2/modules/mod_python.so
>
> 
> SetHandler python-program
> PythonHandler django.core.handlers.modpython
> SetEnv DJANGO_SETTINGS_MODULE mysite.settings
>
> PythonDebug On
> PythonPath "['/home/issam/Workspace/Django/DjangoCode/', 
> '/home/issam/Workspace/Django/DjangoCode/mysite/'] + sys.path"
> 
>
> to help you out there, my settings.py file lives in
> /home/issam/Workspace/Django/DjangoCode/mysite/mysite
>
> I wish i could get help from you guys and that you've got sufficient
> details to help me out with this.
>
> Thanks in advance.
>
> --
> 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.
>
> --
> 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.
>

-- 
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: login page shouldn't open when I am already logged in, but it does !

2012-11-20 Thread Issam Outassourt
Hi,

Well what you could do actually, and it's of commun use is to give your
user a session-cookie id, which you can generate based on some informations
in the header, typically his login, his ip adress, his password, his
user-agent...
As he tries to get the login page, challenge him by checking if the cookie
is set.
If it is set, you should recompute the value and check wether it matches.
If it does, then you can redirect the response to another url, otherwise
you show back the login page.

Well, i'll give you the structure of the code :

*login page*

if(cookie_session_id is set):

calculate new_cookie_session_id(remarkable data_headers, database
information,...) //through concatenation and hashes
if (new_cookie_session_id == cookie_session_id):
 return redirection_to_main_page
else:
 return
what_should_be_the_template_that_allows_the_user_to_identify_him_self
else:
return
what_should_be_the_template_that_allows_the_user_to_identify_him_self


*submit_page*
/* after the user gets to give his own parameters and submit the form
you should manage the data with a view function that sets the
cookie_session_id for the session */


if(the_user_has_the_right_to_authenticate_with_submitted_values):
 calculate cookie_session_id(remarkable data_headers, database
information,...)
 set cookie_session_id
 return the_user_main_page
else:
 return an_error_and_allow_your_user_to_log_again // or something
of that kind

DONE !
The idea behind that is that if the facility is not offered or you did not
afford the time to check the documentation, you can try to solve your
problem by your own. Yet more, you should consider checking the
cookie_session_id any time the user tries to browse a page that contains
sensitive or not public information. What would help you do so is to add a
widget in all pages that shows the login_form if not logged or
login+photo+profile_link (be creative and make sure you check what happens
security wise) information (template power, if you know what i mean ;))

One thing to add is that to compute the value you're looking for, what is
advised generally is to get important information that you believe identify
well, or uniquely your user, concatenante all the stuff and hash it with
very common hash algorithms such as md5, sha1...
More to it, if you want to make sure that you don't have to calculate the
cookie_session_id each time, all you need is to create a Class that
inherits from models.User, add a ForeignKeyField that holds a list of
couples coming from another table that you create and that can hold the
cookie_session_id of your users and the last_request_date

Class SessionId(models.Model):
  session_hash = models.TextField(whatever options you want)
  last_request_date = models.DateTimeField(feel free to customize)

The purpose of this is to make sure that you update SessionId entries each
time you receive a request, to make sure that outdated connections can be
deleted and to allow your users to connect through different platforms at
the same time, as the value of the cookie_session_id could depend as well
on something unique to each machine (their ip adress for example, and their
user-agent)

So, your structure will change from that thing above to the following :

*login page*

if(cookie_session_id is set):

calculate new_cookie_session_id(remarkable data_headers, database
information,...) //through concatenation and hashes
if (new_cookie_session_id == cookie_session_id,
*and the session is not expired*):
 return redirection_to_main_page
else:
 *make sure that the user is not authenticated and clear
the foreign key entry if needed (that is to say if it exists and the
session is outdated)*
 return
what_should_be_the_template_that_allows_the_user_to_identify_him_self
else:
return
what_should_be_the_template_that_allows_the_user_to_identify_him_self


*submit_page*
/* after the user gets to give his own parameters and submit the form
you should manage the data with a view function that sets the
cookie_session_id for the session */


if(the_user_has_the_right_to_authenticate_with_submitted_values):
 calculate cookie_session_id(remarkable data_headers, database
information,...)
 set cookie_session_id
 *add according entry in the foreignkey field, adding it as well in
the sessionid table*
 return the_user_main_page
else:
 return an_error_and_allow_your_user_to_log_again // or something
of that kind


I hope I gave you sufficient hints.
Feel free to ask for more explanations if needed. I would be happy to help

Regards,


2012/11/20 Loai Ghoraba 

> Hi all
>
> I am trying to build a login page using Django auth app, it is all working
> nice but there is one problem: If I browse to accounts/login (the login
> url) when I am already logged in, in normal situation

Re: Can't get Web font loader in django

2012-11-20 Thread Issam Outassourt
{
 "error": {
  "errors": [
   {
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit for Unauthenticated Use Exceeded.
Continued use requires signup.",
"extendedHelp": "https://code.google.com/apis/console";
   }
  ],
  "code": 403,
  "message": "Daily Limit for Unauthenticated Use Exceeded. Continued
use requires signup."
 }
}


When I follow the link you passed through, I (give it a try) found
this more detailed response.
What you actually need to do is within your view that renders the page
requirements log in to your google
account, retrieve the file, and pass it to your template so it
incorporates your response within the html
web page.

In your head section template all you need to do is something of this kind :

{% for jsscript in jsscript_list %}

{{ jsscript }}

{% endfor %}

assuming that jsscript is the text jsscript that you want to add to
your web page.
You can use pycurl's python module to request the .js file that's needed.

Hope this helped,

Issam



2012/11/21 Chris Pagnutti 

> Hi.  I'm trying to get the Google Web Font loader via
> http://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js";>
> in my  section.
> But when I load the page I get (in Chromium's console) this message:
> GET https://www.googleapis.com/webfonts/v1/webfonts 403 (Forbidden)
> HOWEVER, if I call the webfonts.js script in a pure HTML/Javascript page
> (not running behind the django development server) it works fine.
>
> I can request other googleapis resources without problems, e.g.
> http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js";>
> works fine.
>
> Any ideas about what's going wrong?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/U-KJVz1N_McJ.
> 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.
>

-- 
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: Request for inspiration on business system

2012-11-21 Thread Issam Outassourt
Well, I do not totally agree with your point.
The problem with virtual environments such as these is that you have
trouble sometimes figuring out what actually happens behind the scripts
that are used to initialize your environment. Thus comes a natural habit
that I personally developed which is to say, whatever external tool that
you need a specific version for, get the latter version and install it
within a directory that would look like something of this kind
/external/django/bin/
And add that directory to your Django project path in your settings.py
This has the advantage to let you know when you deploy your app, which are
the real specifics that you need to install back again on your development
server.

Did that help ?
Again, it's my personal opinion. Be careful to choose what suits you.

--
Issam Outassourt
Le 21 nov. 2012 16:39, "Javier Guerra Giraldez"  a
écrit :

> On Wed, Nov 21, 2012 at 10:11 AM, Peter Edström 
> wrote:
> > You recommend using virtualenv. Why and in what scenarios?
>
> always.
>
> each and every time i haven't used it, i've regretted it later.  it
> not only lets you experiment  but also in deployment you're guaranteed
> a stable environment.  Also it makes it quite easy to reproduce the
> deployed environment in your desktop long time afterwards, when you've
> already forgotten how it was development before the latest and
> greatest versions of everything.
>
> --
> Javier
>
> --
> 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.
>
>

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