How can I send an iCalendar email attachment with Django? - python

I want to send an iCalendar http://en.wikipedia.org/wiki/ICalendar email attachment using Django. Is there an open source library to build an iCalendar file in Python and/or available for Django?

As stated before, there is vobject, that is working fine (I have used it recently).
You can find good information about ical, vobject and django in this blog post :
http://blog.thescoop.org/archives/2007/07/31/django-ical-and-vobject/

I've used MaxM's icalendar module. It can build and parse iCalendar files.

There's also vobject which was developed for the Chandler project and seems to be more actively maintained. It's also BSD-licensed which might be important for your use case.

Related

How to use a async library in Django view?

I need to use a Python library that handles requests through the API of a web service. This library is an asyncio supported library. So I can't use it in a Django view by following the traditional and appropriate ways..
So what should I do to overcome this issue? I just thought that I can create a .py script and it would handle this library and I would use it in my Django view with os.system('...py') but it just looks awful.
Could you help me to find a way that looks just "normal"?

Overwriting variables in system libraries (smtplib.py)

So I'm using Flask for a website and I'm using the extension Flask Mail to send emails for me. Unfortunately, my email server doesn't support CRAM_MD5 (for a valid reason) so when smtplib.py (Python system library file) reaches the line that is:
preferred_auths = [AUTH_CRAM_MD5, AUTH_PLAIN, AUTH_LOGIN]
it uses CRAM, and fails because of an authentication error. On my development server, I just edited the file and switch the order of PLAIN and CRAM and faced no problems. My system admin doesn't want to make this change every time he does a server build if he can help it so I was wondering if there was a way I could overwrite that system library variable from my Flask application? My Flask application is a little large so if there is a way to do this, I can post a structure of my application. I mostly want to know if it is possible to overwrite variables in system libraries and if so, the standard procedure for doing so. Thanks!

How to use Python and Mailchimp to send an email?

I have been reading a lot on the Internet to know how I can use Python to send emails using mailchimp API. It seems that the website is so complected and doesn't have any example.
Please, could you guide me to any example including a Python use?
What I tried so far:
I installed the library from pip using:
pip install mailchimp;
I have created the campain;
I have created the lists;
But yet, I couldn't know how to send the emails programmatically.
If you want to trigger a campaign see:
https://apidocs.mailchimp.com/api/2.0/campaigns/send.php
The typical module mailchimp at pypi supports it as followed.
from mailchimp import Mailchimp
mailchimp = Mailchimp(api_key)
mailchimp.campaigns.send(campaign_id)
Sourcecode at: https://bitbucket.org/mailchimp/mailchimp-api-python/src/32ed2394d6b49d7551089484221fa3ee019bee37/mailchimp.py?at=master
Hope it helps.
Cheers,
mrcrgl

download a file from a website which requires authetication using python

I am trying to download a CSV file from a website using python 2.7. I already found some posting about how to retrieve files.
http://www.blog.pythonlibrary.org/2012/06/07/python-101-how-to-download-a-file/
How do I download a file over HTTP using Python?
However, the site that I am trying to access requires authentication: id and password. I was wondering if anyone out there might share an example of how to download a file with authentication barrier.
You can use requests module, and its documentation.

What packaging option are available for python/django

I am starting on developing a django application on a shared webhosting server(alwaysdata.com).
I would like to understand what are the packaing options available to package a django application (preferably in compiled form)
I would like to setup the source code repository on my system and build using the python packaging and deploy the package on alwaysdata.com.
I would like the option of not having to share the source code on alwaysdata.com.
Looking at pip , I am not able to find this option.
EDIT
A few more clarification: I would need the ability to not share the sourcecode since it contains the "API secret key" which I would not want to compromise. The more I look into it , the more i believe that there is no way for me to distribute binary only distribution.
I've found fabric to be a pretty nice tool for deploying Django projects. To compile your python code you can use compileall:
python -m compileall <dir>
How is this API key used? Is it a google maps api? Is it provided in scripts that go to the browser? If so, it's already out in the open, anyone using your site will see it, so you're trying to provide a $100 lock for a $0.01 piece of information. If it's a google maps api, it's not secured by keeping it hidden, but rather it's tied to a domain/directory (IIRC).
Can you share a little more what the API key is and is for, then maybe we can help you find a better solution to keep it secure.
Do you think you have to share your source code if you host your application on a 'shared hosting' provider? That's not the case. Your source code should still be private to you but the administrators of your hosting provider can get it too. Other normal Joe Users of the service shouldn't have access to your source code, or your database too. If they do, then get another shared hosting provider!

Categories