Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template tag url needs refactoring #3

Closed
bernardopires opened this issue Jul 7, 2012 · 9 comments
Closed

Template tag url needs refactoring #3

bernardopires opened this issue Jul 7, 2012 · 9 comments

Comments

@bernardopires
Copy link
Owner

Basically 100% of the code was copied from Django's source, just to be able to remove settings.TENANT_URL_TOKEN from the URL. There should be a smarter way to do this.

@ghost ghost assigned bernardopires Jul 7, 2012
@acmeguy
Copy link
Contributor

acmeguy commented Feb 1, 2013

from django.template import Library
from django.template.defaulttags import url as default_url, URLNode
from tenant_schemas.utils import clean_tenant_url

register = Library()

class SchemaURLNode(URLNode):

def __init__(self, url_node):
    super(SchemaURLNode, self).__init__(url_node.view_name, url_node.args, url_node.kwargs, url_node.asvar, url_node.legacy_view_name)

def render(self, context):
    url = super(SchemaURLNode, self).render(context)
    return clean_tenant_url(url)

@register.tag
def url(parser, token):
return SchemaURLNode(default_url(parser,token))

@bernardopires
Copy link
Owner Author

Hi acmeguy, thanks for replying to this issue! Would you like to send a patch with your code?

@acmeguy
Copy link
Contributor

acmeguy commented Feb 2, 2013

Hi,

Sure I will.

How much work would it be to get Shared Applications working?

Regards,
-Stefan

On Sat, Feb 2, 2013 at 3:10 PM, Bernardo Pires Carneiro <
notifications@github.com> wrote:

Hi acmeguy, thanks for replying to this issue! Would you like to send a
patch with your code?


Reply to this email directly or view it on GitHubhttps://github.com//issues/3#issuecomment-13031864.

@bernardopires
Copy link
Owner Author

Thanks!

Well, I don't know how much work it would be because I don't how to implement it. Are you aware of any way to only call syncdb on particular applications or models? That would be the ideal solution and I'd gladly implement it.
A simple non-ideal solution you can do yourself, if you want, is simply adding public to the search path. But all models would still be synced to all the tenants and thus this would required you deleting tables manually to achieve what you want.

@acmeguy
Copy link
Contributor

acmeguy commented Feb 2, 2013

Well, I could live with having the tables in too many places if they would be empty where they are not needed. I need the ability to flag Model tables which should be apart of the schema and leave global Models un-flagged.

@bernardopires
Copy link
Owner Author

The thing is, every time you call sync_schemas, it's going to add all
models to all schemas, including public. If your search path is "tenant,
public", it's always going to search first at "tenant" and then at
"public". If the table is found at "tenant", then it's not going to check
public, and you will have no shared app. So you have to delete the shared
tables from all your tenants, every time you sync the database. This way
it's going to search "tenant", not find the desired table and then it will
find the table at "public". Do you understand what I mean?

2013/2/2 Stefán Baxter notifications@github.com

Well, I could live with having the tables in too many places if they would
be empty where they are not needed. I need the ability to Model tables
which should be apart of the schema and leave global Models un-flagged.


Reply to this email directly or view it on GitHubhttps://github.com//issues/3#issuecomment-13033233.

Bernardo Pires Carneiro

@acmeguy
Copy link
Contributor

acmeguy commented Feb 2, 2013

Yeah I understand (now). That also means that there is no integrity between schemas, right?, and that is not acceptable. I wish there was a good way to achieve this, it would make my life so much easier.

@acmeguy
Copy link
Contributor

acmeguy commented Feb 2, 2013

I moved over to the proper issue (sorry for tainting this one)

@bernardopires
Copy link
Owner Author

What do you mean with integrity between schemas? If we find out how to only
syncdb a particular app/model instead of all apps that would be a life
saver, we wouldn't need to delete tables anymore. Maybe we can write our
own version of syncdb that only syncs a particular app, that shouldn't be
that hard (I think).

2013/2/2 Stefán Baxter notifications@github.com

Yeah I understand (now). That also means that there is no integrity
between schemas, right?, and that is not acceptable. I wish there was a
good way to achieve this, it would make my life so much easier.


Reply to this email directly or view it on GitHubhttps://github.com//issues/3#issuecomment-13033425.

Bernardo Pires Carneiro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants