Re: About unit testing

2010-01-22 Thread Larrik Jaerico
What are you actually trying to accomplish?

On Jan 22, 6:25 am, Gabriel Reis  wrote:
> Hi,
>
> I would like to know if it is mandatory to create an application and define
> my model in the models.py file or if it is possible to define a model
> locally in my test method (inside my TestCase class) and interact with it
> and saving without creating an application and the models.py. In other
> words, is it possible to force the creation of the table inside the test
> method?
> Example:
>
> class MyTestCase(TestCase):
>
>     def test_something(self):
>         class MyModel(models.Model):
>             foo = CharField(max_length=10)
>
>         call_something_to_sync_db()
>
>         m = MyModel(foo='something')
>         m.save()
>
> Thanks for your attention!
>
> Kind regards,
>
> Gabriel
>
> --
> Gabriel de Carvalho Nogueira Reis
> Software Developer
> +44 7907 823942

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Creating a ISP control panel with Django.

2009-12-30 Thread Larrik Jaerico
I would forget the signals, and override your model's save() function
instead. That should give you all of the functionality you are asking
for, and be much less of a headache.

On Dec 29, 11:11 pm, Marc Aymerich  wrote:
> Hi everyone,
>
> I just started developing my first web application, I chose Django for this
> job and I'm so excited with it. It's a control panel with billing
> system for the ISP which I'm working for. This control
> panel allows customers and our admins to add domains, email accounts, ftp
> accounts, databases... and then bill. As it is the first time i'm using
> django, i'd like to share with you how im thinking to implement it so I can
> be sure I'm doing fine, respecting django philosophy :).
>
> *I've defined the database model in models.py
>
> *I've created two instances of the AdminSite, (one for admins, another for
> customers)
>
> *The database can be updated by 3 differents ways:
>
> +Admin panel
>
> +Customer panel
>
> +Synchronization app (to allow sysadmins to do modifications directly on the
> system without loosing consistence between the database and the system)
>
> *For the admin and the customer panel I want to override the function
> save_model via /contrib/admin/options.py. I want to call there a function so
> a resource is created in the system, ex: create_domain(). ¿Is that the best
> place to call create_domain()?
>
> *The synchronization app is called by cron each 'X' time. via 
> wgethttp://panel.mydomain.org/app/
> syncrhon 
> itzation.
> It looks up for changes and saves them into the database.
>
> *Every time that someone creates a new resource (ex. add domain) I need to
> log it into "orders" table (to bill customers later). In order to preserve
> data consistency I think the best way to do this is using the signal
> django.db.models.signals.pre_save.
> At this point I have a few questions:
>
> -Is using this signal is the best way? If this signal fail (don't insert a
> row in orders table), is the default behaviour cancelling obj.save()
> function? or domain is saved anyway in the database? If that's the case,can
> the function that calls obj.save() know that the signal has failed?
>
> I appreciate any kind of comment!
>
> thank you a lot for reading until here!
>
> Marc

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: django error page: traceback too shallow?

2009-12-09 Thread Larrik Jaerico
I've definitely experienced missing levels in the traceback. I don't
have anything reproducible, but notcourage isn't making it up.

On Dec 8, 8:37 am, Karen Tracey  wrote:
> On Thu, Dec 3, 2009 at 1:24 AM, notcourage  wrote:
> > def home (request):
>
> >        if (request.user.is_authenticated()):
> >                artifacts = Artifact.objects.filter
> > (member__exact=request.user.profile.id)
> > ...
> >        else:
> > ...
>
> > In this case, the user is authenticated but the predicate is failing
> > as expected because user.profile is NULL. The traceback is just odd.
>
> I have not seen anything like missing levels in a traceback, nor can I
> recreate anything like what you are reporting based on the information
> provided.  If you can post a complete small example (models, url patterns,
> view) that demonstrates what you see, someone might be able to help more.
>
> 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-us...@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: Discovering the ip/port in use by runserver

2009-10-27 Thread Larrik Jaerico

Perhaps he is looking for a way to get the values passed to runserver,
then?

On Oct 27, 3:17 am, Jani Tiainen  wrote:
> tow kirjoitti:
>
> > If you're running your django server through ./manage.py runserver, is
> > there a way, from within the django process, to discover which  IP
> > address and port are in use?
>
> It doesn't use anything it just listens whatever you specified at
> startup. Default is any local address (localhost), port 8000. Anything
> beyond that you know since you have to specify it explicitly.
>
> --
> Jani Tiainen
--~--~-~--~~~---~--~~
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: how to deploy Django on the web server?

2009-08-08 Thread Larrik Jaerico

I'll bet a lot of the mailing list will faint when they see this, but
I've gotten it to work pretty easily by just dropping the django
directory directly into my project directory.

On Aug 8, 8:24 am, justin jools  wrote:
> ok well thanks for your reply:
>
> first I have free access and they have told me python is installed but it's
> not working as I ran a hello world test script which doesbt execute. That is
> the first of my problems.
>
> My second problem is installing Django...
>
> and third configuring the django scripts to run as outlined in the django
> book, but I am stuck and the first and second hurdles...
>
> I have been looking for a web host server that does support but seems there
> isnt any.. python support is a paid for service.
>
> 
>
> If you can offer any advice here its would be great. I guess the first thing
> i need to do is bug the administrator to get a Python test script running.
>
> On Fri, Aug 7, 2009 at 10:45 PM, Daniel Roseman wrote:
>
>
>
> > On Aug 7, 9:56 pm, justin jools  wrote:
> > > thanks for the reply but I have access to a server for free so I wanted
> > to
> > > set it up myself, how can it be so difficult? Django is renowned as an
> > easy
> > > rapid development framework so why is it so difficult to deploy?
>
> > You haven't said why you think it's difficult. The documentation is
> > clear, and most people here have found it fairly easy to deploy. What
> > has been your problem? Why has the Django book not told you want you
> > want?
> > --
> > 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: switching menu items on and off - dynamic urls?

2009-06-29 Thread Larrik Jaerico

I was afraid of middleware too, but it's really not bad at all. Just
remember that the URL patterns are only processed once.

On Jun 27, 7:41 am, Kenneth Gonsalves  wrote:
> On Friday 26 June 2009 21:19:30 Rajesh D wrote:
>
>
>
> > > I have a conference management application. It has a list of menu items
> > > on the lefthand side. These menus are created by a templatetag from a
> > > list of menus in views.py. At various stages of the conference, menu
> > > items have to be enabled or disabled. For example, 'submit talk' has to
> > > be hidden after the last date for talk submission is over. At present I
> > > am doing this by commenting out the menu item in views.py and commenting
> > > out the corresponding url inurls.py. But this involves the admins
> > > delving into code, which is not a good thing as there is no guarantee
> > > that the admins will be programmers. The menu items can be put in a
> > > model, and have a boolean field 'activate'. That is not a problem. But if
> > > the url is not commented out inurls.py, there is nothing to prevent the
> > >userfrom directly typing in the url. So is there some way where these
> > >urlscan also be stored in a model so that the admin just has to set
> > > 'activate' to false and the menu will not appear and the url will not be
> > > available for theuserto directly type it in?
>
> > You could use custom middleware code to set request.urlconf[1] from a
> > function that dynamically puts together the menuURLsbasedon your
> > model's activate flag.
>
> > For an example of dynamically constructing URL patterns at run time,
> > see Django Admin's sites.AdminSite.get_urls method[2]. Note that this
> > admin method isn't called per request but the examply is still useful
> > to understand how simple it is to return a custom URL pattern list.
> > The key is to wire that function into the custom middleware mentioned
> > above.
>
> thanks for the detailed reply, but I am terrified of going any where near
> middleware. I compromised by making a decorator that checks whether the menu
> item is enabled when ever a view function is called from that menu. Works for
> me (am fighting a deadline).
> --
> regards
> kghttp://lawgon.livejournal.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: Field type for 13 digit positive integer?

2008-09-03 Thread Larrik Jaerico

I was looking for some extremely large integers as well, so you aren't
alone. Though at the moment I can't remember what I needed them for.

On Sep 2, 4:00 pm, coan <[EMAIL PROTECTED]> wrote:
> For now I was planning to store ISBN13 and 13 digit ean codes.
>
> In mysql a bigint field would hold these, but I see no corresponing
> fieldtypes in django for bigints -
> the positiveintegerfield sets itself up as an int(10) signed field
> type in mysql. -
> I guess I could store them as charfields, but I think lookups go
> faster in a bigintfield.
>
> On Sep 2, 9:50 pm, tchendrix <[EMAIL PROTECTED]> wrote:
>
> > the reason i'm asking is that digits 14 and 15 will be alphanumeric so
> > add another field or two for that data (char?) and use bigint to hold
> > the numerical data
>
> > coan wrote:
> > > On Sep 2, 9:36 pm, tchendrix <[EMAIL PROTECTED]> wrote:
>
> > >> that looks like it's for an EAN code... how are you planning on EAN14
> > >> and EAN 15?
>
> > > I will take them on one digit at a time :-)
> > > First I have to solve my 13 digit problem.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Audit Trail

2008-08-24 Thread Larrik Jaerico

Sérgio,

Sorry about the **kwargs thing, my fault. I'm the one who patched
AuditTrail to reflect the newest version of Django, but since I have
some custom code in there I had to go line-by-line and figure out what
to bring back to the website. I missed the **kwargs thing, though, it
seems.

-Larrik Jaerico

On Aug 21, 10:25 am, Sérgio Durand <[EMAIL PROTECTED]> wrote:
> Hi Erick,
>
> It was working on r8339.
> I've updated django this morning to r8460 to and still working !!
>
> What is "history Manager" that you said ?
>
> look how i'm using audit trail:
> 1) i have my 'ordinary' model (without audit trail feature)
> 2) i get the audit trail code and drop it into site-packages python
> directory (it works if you put on root dir of your django project too)
> 3) put import line on your model
> 4) put an 'extra' attribute in your model (that i called 'history') to
> use audit trail.
> 5) and finnaly, run the magic command 'syncdb'.. or, sqlall ,
> you should see all the sql generated by django.
>
> follows my (very) simple example:http://dpaste.com/hold/72943/
>
> Try again with a simple example like that ... if did't work, send the
> error message...
>
> Good luck!!! ;)
>
> Sergio Durand
>
> erikcw escreveu:
>
> > Hi Sergio,
>
> > I updated my code with your changes, and it still doesn't seem to be
> > working.  I don't have the history Manager in my model.
>
> > Is it working for you?  Are you using the latest trunk?
>
> > Thanks!
> > Erik
>
> > On Aug 19, 12:15 pm, Sérgio Durand <[EMAIL PROTECTED]> wrote:
>
> >> Hi people,
>
> >> Finally i've got Audit Trail [1] working again !!! :)
> >> I'm not a django/python expert (i've started studying 2 months ago), but
> >> after fighting with "python manage.py validate" and searching in google,
> >> i've got the solution... the problem basically was missing **kwargs
> >> arguments in some handler functions (because changes made in r8223).
> >> Maybe this problem is very simple (in fact i think it is), but i've
> >> spent several hours (and learned a lot of things too) to get this working.
> >> This was my first code contribution and i'm very glad for that!!
>
> >> Sergio Durand
>
> >> [1]:http://code.djangoproject.com/wiki/AuditTrail
>
> >> ps: i hope i didn't make a code mistake and sorry my english !!! ;

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